-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add a spec for #transfer_to_location to verify the attributes of the new shipment #1141
Add a spec for #transfer_to_location to verify the attributes of the new shipment #1141
Conversation
it 'transfers unit to a new shipment with given location' do | ||
order = create(:completed_order_with_totals, line_items_count: 2) | ||
shipment = order.shipments.first | ||
variant = order.inventory_units.collect(&:variant).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer map
over collect
.
e4f54c6
to
17887fd
Compare
The main problem is that splitting a completed order doesn't fill the address and the shipping method
https://github.com/solidusio/solidus/blob/master/core/app/models/spree/order_shipping.rb#L51 when creating a Spree::Carton called on the after_transition hook for shipped. |
Thanks, this makes sense to me. @forkata Any idea why this was omitted in the first place? Btw really nice specs. |
@mamhoff It appears that the address association on shipment isn't used consistently and this was probably omitted by mistake. I looked through the history of this code and as far back as I could trace it, it seems this would have been an issue b252e9a. Related to this there is a proposed change to completely remove the address association on shipment here #1138 and always use the |
@forkata yeah I read the proposal to delegate to |
@hectoregm We can definitely use the spec, thank you for adding that. I would keep an eye on what the decision is regarding the |
shipment = order.shipments.first | ||
variant = order.inventory_units.collect(&:variant).first | ||
|
||
expect do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice if we can wrap all these expectations in an aggregate_failures
block so we can see multiple failures in a single run.
http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec%2FMatchers%3Aaggregate_failures
a78f7ac
to
3b5ee23
Compare
shipment after the split.
3b5ee23
to
39fd963
Compare
@forkata made the changes we mentioned and added aggregate_failures block |
👍 |
When a shipment split is done the new shipment created by #transfer_to_location doesn't associate
the order shipping address to this new shipment so all new shipments have nil for address.