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 loading transfer shipments #1781

Merged
merged 3 commits into from
Apr 5, 2017

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Mar 17, 2017

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.

context "if the user is not authorized to update the shipment" do
let(:user) { create(:user, spree_api_key: 'abc123') }

custom_authorization! do |user|

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}]) }

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.

@mamhoff mamhoff force-pushed the fix-loading-transfer-shipments branch from 675b9ea to 8220d5d Compare March 17, 2017 14:21
context "if the user can not destroy shipments" do
let(:user) { create(:user, spree_api_key: 'abc123') }

custom_authorization! do |user|

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|

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}]) }

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.
@mamhoff mamhoff force-pushed the fix-loading-transfer-shipments branch from 8220d5d to 592551b Compare March 17, 2017 14:47
Copy link
Member

@tvdeyen tvdeyen left a 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.

@jhawthorn jhawthorn merged commit add2c13 into solidusio:master Apr 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants