From 4cc8eb90fc1f1e57588f93144744b53df1f707e7 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Tue, 30 Jun 2015 12:54:03 +1000 Subject: [PATCH] Refactor code for brevity --- app/controllers/checkout_controller.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index f13d28d94e..b23a57ebde 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -83,17 +83,14 @@ class CheckoutController < Spree::CheckoutController params[:order] end + # Perform order.next, guarding against StaleObjectErrors def advance_order_state(order) - result = false - tries = 3 + tries ||= 3 + order.next - begin - result = order.next - rescue ActiveRecord::StaleObjectError - retry unless (tries -= 1).zero? - end - - result + rescue ActiveRecord::StaleObjectError + retry unless (tries -= 1).zero? + false end