From 25e0262364648cb6a18ce0205fec17e701129d8d Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Sat, 13 Mar 2021 12:12:16 +0000 Subject: [PATCH] Adapt spec to new rspec syntax with params and no xhr --- .../enterprises_controller_spec.rb | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index cdfa2ef964..1170b7de6e 100644 --- a/spec/controllers/enterprises_controller_spec.rb +++ b/spec/controllers/enterprises_controller_spec.rb @@ -18,7 +18,7 @@ describe EnterprisesController, type: :controller do end it "sets the shop as the distributor on the order when shopping for the distributor" do - get :shop, id: distributor + get :shop, params: { id: distributor } expect(controller.current_distributor).to eq(distributor) expect(controller.current_order.distributor).to eq(distributor) @@ -29,7 +29,7 @@ describe EnterprisesController, type: :controller do before { allow(controller).to receive(:spree_current_user) { user } } it "sets the shop as the distributor on the order when shopping for the distributor" do - get :shop, id: distributor + get :shop, params: { id: distributor } expect(controller.current_distributor).to eq(distributor) expect(controller.current_order.distributor).to eq(distributor) @@ -39,11 +39,11 @@ describe EnterprisesController, type: :controller do it "sorts order cycles by the distributor's preferred ordering attr" do distributor.update_attribute(:preferred_shopfront_order_cycle_order, 'orders_close_at') - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to eq([order_cycle1, order_cycle2].sort_by(&:orders_close_at)) distributor.update_attribute(:preferred_shopfront_order_cycle_order, 'orders_open_at') - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to eq([order_cycle1, order_cycle2].sort_by(&:orders_open_at)) end @@ -64,23 +64,23 @@ describe EnterprisesController, type: :controller do preferred_exchange_tags: "wholesale", preferred_matched_order_cycles_visibility: 'hidden') - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2, order_cycle3 allow(controller).to receive(:spree_current_user) { user } - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2, order_cycle3 oc3_exchange.update_attribute(:tag_list, "wholesale") - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2 expect(assigns(:order_cycles)).not_to include order_cycle3 customer.update_attribute(:tag_list, ["wholesale"]) - get :shop, id: distributor + get :shop, params: { id: distributor } expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2, order_cycle3 end end @@ -89,7 +89,7 @@ describe EnterprisesController, type: :controller do line_item = create(:line_item) controller.current_order.line_items << line_item - get :shop, id: distributor + get :shop, params: { id: distributor } expect(controller.current_order.distributor).to eq(distributor) expect(controller.current_order.order_cycle).to be_nil @@ -97,7 +97,7 @@ describe EnterprisesController, type: :controller do end it "should not empty an order if returning to the same distributor" do - get :shop, id: current_distributor + get :shop, params: { id: current_distributor } expect(controller.current_order.distributor).to eq current_distributor expect(controller.current_order.line_items.first.variant).to eq line_item.variant @@ -117,7 +117,7 @@ describe EnterprisesController, type: :controller do end it "redirects to the cart" do - get :shop, id: current_distributor + get :shop, params: { id: current_distributor } expect(response).to redirect_to cart_path end @@ -129,7 +129,7 @@ describe EnterprisesController, type: :controller do order.save order_cycle1.update_attribute :orders_close_at, Time.zone.now - get :shop, id: distributor + get :shop, params: { id: distributor } expect(controller.current_order.distributor).to eq(distributor) expect(controller.current_order.order_cycle).to eq(order_cycle2) @@ -139,7 +139,7 @@ describe EnterprisesController, type: :controller do it "sets order cycle if only one is available at the chosen distributor" do order_cycle2.destroy - get :shop, id: distributor + get :shop, params: { id: distributor } expect(controller.current_order.distributor).to eq(distributor) expect(controller.current_order.order_cycle).to eq(order_cycle1) @@ -157,16 +157,16 @@ describe EnterprisesController, type: :controller do it "responds with status of 409 when the permalink matches an existing route" do # get :check_permalink, { permalink: 'enterprise_permalink', format: :js } # expect(response.status).to be 409 - xhr :get, :check_permalink, permalink: 'map', format: :js + get :check_permalink, xhr: true, params: { permalink: 'map', format: :js } expect(response.status).to be 409 - xhr :get, :check_permalink, permalink: '', format: :js + get :check_permalink, xhr: true, params: { permalink: '', format: :js } expect(response.status).to be 409 end end context "checking access on nonexistent enterprise" do before do - get :shop, id: "some_nonexistent_enterprise" + get :shop, params: { id: "some_nonexistent_enterprise" } end it "redirects to shops_path" do