Fix checkout confirmation page blank (access denied) when checking out anonymously - BugHerd #139

This commit is contained in:
Rohan Mitchell
2013-11-08 15:27:11 +11:00
parent 317b2f1ced
commit 283401d6fe
2 changed files with 15 additions and 0 deletions

View File

@@ -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

View File

@@ -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