-
-
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
Fix loading transfer shipments #1781
Fix loading transfer shipments #1781
Conversation
context "if the user is not authorized to update the shipment" do | ||
let(:user) { create(:user, spree_api_key: 'abc123') } | ||
|
||
custom_authorization! do |user| |
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.
Unused block argument - user. You can omit the argument if you don't care about it.
let(:user) { create(:admin_user, spree_api_key: 'abc123') } | ||
let(:stock_item) { create(:stock_item, backorderable: false) } | ||
let(:variant) { stock_item.variant } | ||
let(:order) { create(:completed_order_with_totals, user: user, line_items_attributes: [{variant: variant}]) } |
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.
Space inside { missing.
Space inside } missing.
675b9ea
to
8220d5d
Compare
context "if the user can not destroy shipments" do | ||
let(:user) { create(:user, spree_api_key: 'abc123') } | ||
|
||
custom_authorization! do |user| |
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.
Unused block argument - user. You can omit the argument if you don't care about it.
context "if the user can not update shipments" do | ||
let(:user) { create(:user, spree_api_key: 'abc123') } | ||
|
||
custom_authorization! do |user| |
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.
Unused block argument - user. You can omit the argument if you don't care about it.
let(:user) { create(:admin_user, spree_api_key: 'abc123') } | ||
let(:stock_item) { create(:stock_item, backorderable: false) } | ||
let(:variant) { stock_item.variant } | ||
let(:order) { create(:completed_order_with_totals, user: user, line_items_attributes: [{variant: variant}]) } |
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.
Space inside { missing.
Space inside } missing.
Prior to this change, calling the transfer_to_{shipment, stock_location} APIs with a non-existing source shipment number would result in a `NoMethodError`. This change changes it to a 404, which I believe is more appropriate. Also, I'm introducing request specs for this endpoint here.
Fulfilling inventory units from another shipment changes the source shipment, and potentially destroys it. Just the `:read` ability for that is not enough.
When a shipment is split entirely (all its inventory units move to the new shipment), it is destroyed. This new ability check accounts for that case.
8220d5d
to
592551b
Compare
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.
LGTM. Thanks 👍
Could we have a CHANGELOG entry? This could effect shops.
When loading shipments to transfer from, the previous code did not verify the shipment actually exists in the database. Also, the ability check was sketchy.
We currently have almost no API specs in this project. This adds one for those two endpoints.