-
-
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
Always pass the new order number on unreturned exchange failures #388
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,12 +53,12 @@ def charge_for_items | |
|
||
end | ||
|
||
private | ||
|
||
def new_order | ||
@new_order ||= Spree::Order.create!(exchange_order_attributes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're making this public it seems like we ought to make it a bit safer to call. i.e. calling |
||
end | ||
|
||
private | ||
|
||
def add_exchange_variants_to_order | ||
@return_items.group_by(&:exchange_variant).map do |variant, variant_return_items| | ||
variant_inventory_units = variant_return_items.map(&:exchange_inventory_unit) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,13 @@ namespace :exchanges do | |
begin | ||
item_charger.charge_for_items | ||
rescue Spree::UnreturnedItemCharger::ChargeFailure => e | ||
failure = {message: e.message, new_order: e.new_order.try(:number)} | ||
failure = { message: e.message } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can now just collapse this into the |
||
rescue Exception => e | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While you're here, if you could get rid of this, I'd really appreciate it. Instead of
just
Rescuing Exception will rescue syntax errors, signal exceptions and such. Things that you shouldn't be rescuing unless you're re-raising them. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah good point; done. |
||
failure = {message: "#{e.class}: #{e.message}"} | ||
failure = { message: "#{e.class}: #{e.message}" } | ||
end | ||
|
||
if failure | ||
failure[:new_order] = item_charger.new_order.number if item_charger.new_order | ||
failures << failure.merge({ | ||
order: item_charger.original_order.number, | ||
shipment: shipment.number, | ||
|
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.
I feel like this should get its own special unit test now lol