Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix complete order factory to have non-pending inventory units #1787

Merged
merged 1 commit into from
Mar 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/lib/spree/testing_support/factories/order_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@

after(:create) do |order|
order.refresh_shipment_rates
order.shipments.each do |shipment|
shipment.inventory_units.update_all state: 'on_hand', pending: false
end
order.update_column(:completed_at, Time.current)
end

Expand All @@ -96,7 +99,6 @@
after(:create) do |order, evaluator|
create(evaluator.payment_type, amount: order.total, order: order, state: 'completed')
order.shipments.each do |shipment|
shipment.inventory_units.update_all state: 'on_hand'
shipment.update_column('state', 'ready')
end
order.reload
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
total: 110,
state: 'complete'
)
expect(order.inventory_units.where(pending: true)).to be_empty
expect(order.inventory_units.where(pending: false)).to_not be_empty
end
end
end
Expand Down
1 change: 1 addition & 0 deletions core/spec/models/spree/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,7 @@
before do
stock_item.set_count_on_hand(10)
stock_item.update_attributes!(backorderable: false)
inventory_unit.update_attributes!(pending: true)
end

subject { shipment.finalize! }
Expand Down