diff --git a/app/controllers/spree/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb index 7bb84f781b..a08f2aa463 100644 --- a/app/controllers/spree/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -20,10 +20,16 @@ Spree::CheckoutController.class_eval do def after_complete distributor = current_order.distributor + token = current_order.token + session[:order_id] = nil clear_current_order_cache current_order(true) + current_order.set_distributor!(distributor) + current_order.tokenized_permission.token = token + current_order.tokenized_permission.save! + session[:access_token] = token end def clear_current_order_cache diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index 3fad655318..08817a01b9 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -26,5 +26,14 @@ describe Spree::CheckoutController do controller.current_order.distributor.should == distributor end + it "should set the new order's token to the same as the old order, and preserve the access token in the session" do + order = controller.current_order(true) + + controller.send(:after_complete) + + controller.current_order.token.should == order.token + session[:access_token].should == order.token + end + end end