Skip to content

Instantly share code, notes, and snippets.

@dhonig
Created September 21, 2015 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhonig/620f44c6edb10a6c2722 to your computer and use it in GitHub Desktop.
Save dhonig/620f44c6edb10a6c2722 to your computer and use it in GitHub Desktop.
spec
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
stock_location.fill_status(a_variant,100)
new_shipment=Spree::Shipment.new(order: order, stock_location: stock_location)
original_shipment=order.shipments.first
order.shipments << new_shipment
order.contents.add(a_variant, 4, nil, original_shipment)
order.save
destination_shipment=order.shipments.find { |x| x.id==new_shipment.id }
original_shipment.transfer_to_shipment(variant, 2, destination_shipment)
binding.pry
order.save
order.shipments.reload
original_manifest_item=original_shipment.manifest.find { |x| x.variant.id==variant.id }
destination_manifest_item=destination_shipment.manifest.find { |x| x.variant.id==variant.id }
expect(original_manifest_item.quantity).to equal(2)
expect(destination_manifest_item.quantity).to equal(2)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment