Skip to content

Instantly share code, notes, and snippets.

View dhonig's full-sized avatar

Daniel Honig dhonig

View GitHub Profile
describe 'Transfers between shipments' do
let(:user) { stub_model(Spree::User, :email => "spree@example.com") }
#populated with order,email bill_address and ship_address,
let(:order) { FactoryGirl.create(:order_with_line_items) }
let(:a_variant){FactoryGirl.create(:variant)}
it 'should It should transfer items between shipments without adding line items' do
stock_location=order.shipments.first.stock_location
variant=stock_location.stock_items.first.variant
def open_adjustments
adjustments = @order.all_adjustments.where(state: 'closed')
adjustments.update_all(state: 'open')
flash[:success] = Spree.t(:all_adjustments_opened)
respond_with(@order) { |format| format.html { redirect_to :back } }
end
def update!(target = nil)
return amount if closed?
if source.present?
amount = source.compute_amount(target || adjustable)
self.update_columns(
amount: amount,
updated_at: Time.now,
)
if promotion?
self.update_column(:eligible, source.promotion.eligible?(adjustable))
@dhonig
dhonig / gist:f2ca099053afe9ca4f31
Created September 10, 2015 16:54
turn off admin alerts
RAILS_ENV=production bundle exec rails runner "Spree::Config.check_for_spree_alerts = false"
context "Searching" do
let!(:taxon) { create(:taxon, name: "shirts") }
let!(:taxon2) { create(:taxon, name: "shoes") }
let!(:a_product) { create(:product, taxons: [taxon], stores: [store],
description: "A product in english", price: 20) }
let!(:another_product) { create(:product, taxons: [taxon, taxon2], stores: [store], price: 80) }
end
@dhonig
dhonig / BooYah
Created April 2, 2014 09:18
EXAMPLE Filtering within a term query
POST /development_en/product/_search
{
"query": {
"filtered": {
"query": {
"bool": {
"must": [
{
"match_all": {}
}
<ListOfEmails>
<Email>
<EmailOID>57712b2a-ab68-4d59-94e9-fd22aaab7c89</EmailOID>
<Sender>Jai King &lt;herqueles3@gmail.com></Sender>
<DateTime>2013-09-06T19:16:22.308Z</DateTime>
<Subject>test subject</Subject>
<ListOfDocuments/>
</Email>
<Email>
<EmailOID>75a0b993-186b-49a5-968f-111cf985866f</EmailOID>
@dhonig
dhonig / gist:6335851
Created August 25, 2013 19:45
MULE startup failure
at org.tanukisoftware.wrapper.WrapperManager$12.run(WrapperManager.java:2788)
Caused by: org.mule.api.config.ConfigurationException: Line 43 in XML document from URL [file:/usr/lib/mule-standalone-3.4.0/apps/itemize-esb-1.0.0-SNAPSHOT/main.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'amqp:connector'. One of '{"http://www.springframework.org/schema/beans":beans, "http://www.springframework.org/schema/beans":bean, "http://www.springframework.org/schema/context":property-placeholder, "http://www.springframework.org/schema/beans":ref, "http://www.mulesoft.org/schema/mule/core":global-property, "http://www.mulesoft.org/schema/mule/core":configuration, "http://www.mulesoft.org/schema/mule/core":notifications, "http://www.mulesoft.org/schema/mule/core":abstract-extension, "http://www.mulesoft.org/schema/mule/core":abstract-mixed-content-extension, "http://www.mulesoft.org/schema/mule/core":abstract-agent, "http://
@dhonig
dhonig / franklinmint-mule.xml
Created June 11, 2012 22:03
this actually works
<flow name="net_suite_test_flow">
<http:inbound-endpoint ref="netsuite_test_endpoint" exchange-pattern="request-response"/>
<logger message="#[groovy:return message.toString();]" level="INFO"/>
<echo-component/>
<netsuite:get-record recordType="INVENTORY_ITEM" id="#[header:INBOUND:internal_id]"/>
<logger message="#[groovy:return message.toString();]" level="INFO"/>
<expression-transformer>
<return-argument evaluator="string" expression="Item: #[groovy:message.payload.storeDescription]"/>
</expression-transformer>
<netsuite:add-list recordType="CASH_SALE">
@dhonig
dhonig / DeployAppToIon.groovy
Created June 5, 2012 23:15
Attempt to deploy to ION
import static groovyx.net.http.ContentType.JSON
import groovyx.net.http.RESTClient
import static groovyx.net.http.Method.GET
import static groovyx.net.http.Method.PUT
import static groovyx.net.http.ContentType.TEXT
import static groovyx.net.http.ContentType.URLENC
@Grab(group = 'org.codehaus.groovy.modules.http-builder',
module = 'http-builder', version = '0.5.2')