diff --git a/spec/controllers/checkout_controller_spec.rb b/spec/controllers/checkout_controller_spec.rb index f7775ba931..ca0d67ab52 100644 --- a/spec/controllers/checkout_controller_spec.rb +++ b/spec/controllers/checkout_controller_spec.rb @@ -84,6 +84,12 @@ describe CheckoutController do order.should_receive(:ship_address=) controller.send(:clear_ship_address) end + + it "sets the new order's token to the same as the old order" do + order = controller.current_order(true) + spree_post :update, order: {} + expect(controller.current_order.token).to eq order.token + end end context "via xhr" do diff --git a/spec/controllers/spree/checkout_controller_spec.rb b/spec/controllers/spree/checkout_controller_spec.rb index e8840c8bad..116c18955b 100644 --- a/spec/controllers/spree/checkout_controller_spec.rb +++ b/spec/controllers/spree/checkout_controller_spec.rb @@ -4,46 +4,19 @@ require 'support/request/authentication_workflow' describe Spree::CheckoutController do - context "After completing an order" do - let!(:order) { controller.current_order(true) } + context 'rendering edit from within spree for the current checkout state' do + let(:order) { controller.current_order(true) } + let(:user) { create(:user) } - it "creates a new empty order" do - controller.reset_order - expect(controller.session[:order_id]).not_to be_nil + before do + create(:line_item, order: order) + + allow(controller).to receive(:skip_state_validation?) { true } + allow(controller).to receive(:spree_current_user) { user } end - it "clears the current order cache" do - controller.reset_order - expect(controller.current_order).not_to eq order - end - - it "sets the new order's distributor to the same as the old order" do - distributor = create(:distributor_enterprise) - order.set_distributor!(distributor) - - controller.reset_order - - expect(controller.current_order.distributor).to eq distributor - end - - it "sets the new order's token to the same as the old order, and preserve the access token in the session" do - controller.reset_order - - expect(controller.current_order.token).to eq order.token - expect(session[:access_token]).to eq order.token - end - end - - context "rendering edit from within spree for the current checkout state" do - let!(:order) { controller.current_order(true) } - let!(:line_item) { create(:line_item, order: order) } - let!(:user) { create(:user) } - it "redirects to the OFN checkout page" do - controller.stub(:skip_state_validation?) { true } - controller.stub(:spree_current_user) { user } - spree_get :edit - response.should redirect_to checkout_path + expect(spree_get(:edit)).to redirect_to checkout_path end end end diff --git a/spec/models/reset_order_service_spec.rb b/spec/models/reset_order_service_spec.rb index 5bcc05e8ea..8577069013 100644 --- a/spec/models/reset_order_service_spec.rb +++ b/spec/models/reset_order_service_spec.rb @@ -41,7 +41,7 @@ describe ResetOrderService do expect(controller.instance_variable_get(:@current_order)).to be_nil end - it 'sets the distributor of the order' do + it 'sets the new order\'s distributor to the same as the old order' do reset_order_service.call expect(new_order)