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

Improve selected_shipping_rate_id= #2355

Merged

Conversation

jhawthorn
Copy link
Contributor

Some somewhat minor changes to Shipment#selected_shipping_rate_id=

  • Fixes an issue where if selected_shipping_rate_id= was passed a bad id, the shipment would have no shipping rate selected. (It will now keep the previous selection)
  • Use update! instead of update, so that exceptions are raised on any errors
  • Wrap the two shipping rate updates in a transaction so that any update errors will be rolled back together
  • Remove an unnecessary save!, all modifications are made on other records.
  • Avoid preforming any updates if we re-assign the already selected rate

The existing code worked fine, but it was odd to perform an update to
de-select the rate and then re-select the same one when it was
unnecessary.
If this fails for any reason, both should be rolled-back
Copy link
Contributor

@cbrunsdon cbrunsdon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me 👍

@jhawthorn jhawthorn merged commit 9a15570 into solidusio:master Nov 8, 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.

3 participants