diff --git a/spec/controllers/admin/bulk_line_items_controller_spec.rb b/spec/controllers/admin/bulk_line_items_controller_spec.rb index 4d94591a0e..cdc1d8c0cc 100644 --- a/spec/controllers/admin/bulk_line_items_controller_spec.rb +++ b/spec/controllers/admin/bulk_line_items_controller_spec.rb @@ -237,7 +237,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "hub enterprise" do before do allow(controller).to receive_messages spree_current_user: distributor1.owner - xhr :put, :update, params + put :update, params: params, xhr: true end it "updates the line item" do diff --git a/spec/controllers/admin/matomo_settings_controller_spec.rb b/spec/controllers/admin/matomo_settings_controller_spec.rb index 8644557a58..0bc9b35a16 100644 --- a/spec/controllers/admin/matomo_settings_controller_spec.rb +++ b/spec/controllers/admin/matomo_settings_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::MatomoSettingsController, type: :controller do it "changes Matomo settings" do expect { - post :update, params + post :update, params: params }.to change { [ Spree::Config[:matomo_url], diff --git a/spec/controllers/api/orders_controller_spec.rb b/spec/controllers/api/orders_controller_spec.rb index 2a5421e9cb..2dfd2dd035 100644 --- a/spec/controllers/api/orders_controller_spec.rb +++ b/spec/controllers/api/orders_controller_spec.rb @@ -133,7 +133,7 @@ module Api end it 'can show only completed orders' do - get :index, format: :json, q: { completed_at_not_null: true, s: 'created_at desc' } + get :index, params: { format: :json, q: { completed_at_not_null: true, s: 'created_at desc' } } expect(json_response['orders']).to eq serialized_orders([order4, order3, order2, order1]) end @@ -145,7 +145,7 @@ module Api end it 'returns pagination data when query params contain :per_page]' do - get :index, per_page: 15, page: 1 + get :index, params: { per_page: 15, page: 1 } pagination_data = { 'results' => 2, diff --git a/spec/controllers/api/product_images_controller_spec.rb b/spec/controllers/api/product_images_controller_spec.rb index 95ee3bd3de..b4858ae49e 100644 --- a/spec/controllers/api/product_images_controller_spec.rb +++ b/spec/controllers/api/product_images_controller_spec.rb @@ -19,14 +19,14 @@ module Api let(:current_api_user) { create(:admin_user) } it "saves a new image when none is present" do - xhr :post, :update_product_image, product_id: product_without_image.id, file: image, use_route: :product_images + post :update_product_image, xhr: true, params: { product_id: product_without_image.id, file: image, use_route: :product_images } expect(response.status).to eq 201 expect(product_without_image.images.first.id).to eq json_response['id'] end it "updates an existing product image" do - xhr :post, :update_product_image, product_id: product_with_image.id, file: image, use_route: :product_images + post :update_product_image, xhr: true, params: { product_id: product_with_image.id, file: image, use_route: :product_images } expect(response.status).to eq 200 expect(product_with_image.images.first.id).to eq json_response['id'] diff --git a/spec/controllers/cart_controller_spec.rb b/spec/controllers/cart_controller_spec.rb index b3f6d46c8f..83cbee70e5 100644 --- a/spec/controllers/cart_controller_spec.rb +++ b/spec/controllers/cart_controller_spec.rb @@ -17,7 +17,7 @@ describe CartController, type: :controller do allow(cart_service).to receive(:populate) { true } allow(cart_service).to receive(:valid?) { true } allow(cart_service).to receive(:variants_h) { {} } - xhr :post, :populate, use_route: :spree, format: :json + post :populate, xhr: true, params: { use_route: :spree, format: :json } expect(response.status).to eq(200) end @@ -26,7 +26,7 @@ describe CartController, type: :controller do allow(cart_service).to receive(:valid?) { false } allow(cart_service).to receive(:errors) { errors } allow(errors).to receive(:full_messages).and_return(["Error: foo"]) - xhr :post, :populate, use_route: :spree, format: :json + post :populate, xhr: true, params: { use_route: :spree, format: :json } expect(response.status).to eq(412) end @@ -34,7 +34,7 @@ describe CartController, type: :controller do allow(cart_service).to receive(:variants_h) { {} } allow(cart_service).to receive(:valid?) { true } expect(cart_service).to receive(:populate).with({}, true) - xhr :post, :populate, use_route: :spree, format: :json + post :populate, xhr: true, params: { use_route: :spree, format: :json } end it "returns stock levels as JSON on success" do @@ -44,7 +44,7 @@ describe CartController, type: :controller do allow(cart_service).to receive(:valid?) { true } allow(cart_service).to receive(:variants_h) { {} } - xhr :post, :populate, use_route: :spree, format: :json + post :populate, xhr: true, params: { use_route: :spree, format: :json } data = JSON.parse(response.body) expect(data['stock_levels']).to eq('my_stock_levels') diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index 86ff995516..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) @@ -150,23 +150,23 @@ describe EnterprisesController, type: :controller do # let(:enterprise) { create(:enterprise, permalink: 'enterprise_permalink') } it "responds with status of 200 when the route does not exist" do - xhr :get, :check_permalink, permalink: 'some_nonexistent_route', format: :js + get :check_permalink, xhr: true, params: { permalink: 'some_nonexistent_route', format: :js } expect(response.status).to be 200 end 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 diff --git a/spec/controllers/user_passwords_controller_spec.rb b/spec/controllers/user_passwords_controller_spec.rb index 72e399adf2..f66c7d1bf8 100644 --- a/spec/controllers/user_passwords_controller_spec.rb +++ b/spec/controllers/user_passwords_controller_spec.rb @@ -49,13 +49,13 @@ describe UserPasswordsController, type: :controller do describe "via ajax" do it "returns error when email not found" do - xhr :post, :create, spree_user: {}, use_route: :spree + post :create, xhr: true, params: { spree_user: {}, use_route: :spree } expect(response.status).to eq 404 expect(json_response).to eq 'error' => I18n.t('email_not_found') end it "returns error when user is unconfirmed" do - xhr :post, :create, spree_user: { email: unconfirmed_user.email }, use_route: :spree + post :create, xhr: true, params: { spree_user: { email: unconfirmed_user.email }, use_route: :spree } expect(response.status).to eq 401 expect(json_response).to eq 'error' => I18n.t('email_unconfirmed') end diff --git a/spec/controllers/user_registrations_controller_spec.rb b/spec/controllers/user_registrations_controller_spec.rb index b659266c64..9e77be34f2 100644 --- a/spec/controllers/user_registrations_controller_spec.rb +++ b/spec/controllers/user_registrations_controller_spec.rb @@ -25,7 +25,7 @@ describe UserRegistrationsController, type: :controller do end it "returns validation errors" do - xhr :post, :create, spree_user: {}, use_route: :spree + post :create, xhr: true, params: { spree_user: {}, use_route: :spree } expect(response.status).to eq(401) json = JSON.parse(response.body) expect(json).to eq("email" => ["can't be blank"], "password" => ["can't be blank"]) @@ -35,7 +35,7 @@ describe UserRegistrationsController, type: :controller do allow(Spree::UserMailer).to receive(:confirmation_instructions).and_raise("Some error") expect(OpenFoodNetwork::ErrorLogger).to receive(:notify) - xhr :post, :create, spree_user: user_params, use_route: :spree + post :create, xhr: true, params: { spree_user: user_params, use_route: :spree } expect(response.status).to eq(401) json = JSON.parse(response.body) @@ -43,7 +43,7 @@ describe UserRegistrationsController, type: :controller do end it "returns 200 when registration succeeds" do - xhr :post, :create, spree_user: user_params, use_route: :spree + post :create, xhr: true, params: { spree_user: user_params, use_route: :spree } expect(response.status).to eq(200) json = JSON.parse(response.body) expect(json).to eq("email" => "test@test.com") @@ -55,7 +55,7 @@ describe UserRegistrationsController, type: :controller do original_locale_cookie = cookies[:locale] cookies[:locale] = "pt" - xhr :post, :create, spree_user: user_params, use_route: :spree + post :create, xhr: true, params: { spree_user: user_params, use_route: :spree } expect(assigns[:user].locale).to eq("pt") I18n.locale = original_i18n_locale diff --git a/spec/performance/shop_controller_spec.rb b/spec/performance/shop_controller_spec.rb index 6a052e67dc..ba116dbc66 100644 --- a/spec/performance/shop_controller_spec.rb +++ b/spec/performance/shop_controller_spec.rb @@ -37,7 +37,7 @@ describe ShopController, type: :controller, performance: true do it "returns products via json" do results = multi_benchmark(3, cache_key_patterns: cache_key_patterns) do - xhr :get, :products + get :products, xhr: true expect(response).to be_success end end