diff --git a/spec/controllers/admin/bulk_line_items_controller_spec.rb b/spec/controllers/admin/bulk_line_items_controller_spec.rb index fa8f628c6c..d40e0682d2 100644 --- a/spec/controllers/admin/bulk_line_items_controller_spec.rb +++ b/spec/controllers/admin/bulk_line_items_controller_spec.rb @@ -20,7 +20,7 @@ describe Admin::BulkLineItemsController, type: :controller do before { allow(controller).to receive_messages spree_current_user: create(:user) } it "should deny me access to the index action" do - spree_get :index, format: :json + get :index, format: :json expect(response).to redirect_to unauthorized_path end end @@ -32,7 +32,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "when no ransack params are passed in" do before do - spree_get :index, format: :json + get :index, format: :json end it "retrieves a list of line_items with appropriate attributes, including line items with appropriate attributes" do @@ -56,7 +56,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "when ransack params are passed in for line items" do before do - spree_get :index, format: :json, q: { order_id_eq: order2.id } + get :index, format: :json, q: { order_id_eq: order2.id } end it "retrives a list of line items which match the criteria" do @@ -66,7 +66,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "when ransack params are passed in for orders" do before do - spree_get :index, format: :json, q: { order: { completed_at_gt: 2.hours.ago } } + get :index, format: :json, q: { order: { completed_at_gt: 2.hours.ago } } end it "retrives a list of line items whose orders match the criteria" do @@ -90,7 +90,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "producer enterprise" do before do allow(controller).to receive_messages spree_current_user: supplier.owner - spree_get :index, format: :json + get :index, format: :json end it "does not display line items for which my enterprise is a supplier" do @@ -101,7 +101,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "coordinator enterprise" do before do allow(controller).to receive_messages spree_current_user: coordinator.owner - spree_get :index, format: :json + get :index, format: :json end it "retrieves a list of line_items" do @@ -113,7 +113,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "hub enterprise" do before do allow(controller).to receive_messages spree_current_user: distributor1.owner - spree_get :index, format: :json + get :index, format: :json end it "retrieves a list of line_items" do @@ -130,7 +130,7 @@ describe Admin::BulkLineItemsController, type: :controller do context "with pagination args" do it "returns paginated results" do - spree_get :index, { page: 1, per_page: 2 }, format: :json + get :index, { page: 1, per_page: 2 }, format: :json expect(line_item_ids).to eq [line_item1.id, line_item2.id] expect(json_response['pagination']).to eq( @@ -139,7 +139,7 @@ describe Admin::BulkLineItemsController, type: :controller do end it "returns paginated results for a second page" do - spree_get :index, { page: 2, per_page: 2 }, format: :json + get :index, { page: 2, per_page: 2 }, format: :json expect(line_item_ids).to eq [line_item3.id, line_item4.id] expect(json_response['pagination']).to eq( diff --git a/spec/controllers/admin/customers_controller_spec.rb b/spec/controllers/admin/customers_controller_spec.rb index b15b5efdd8..6f289dc891 100644 --- a/spec/controllers/admin/customers_controller_spec.rb +++ b/spec/controllers/admin/customers_controller_spec.rb @@ -17,7 +17,7 @@ module Admin end it "returns an empty @collection" do - spree_get :index, format: :html + get :index, format: :html expect(assigns(:collection)).to eq [] end end @@ -34,13 +34,13 @@ module Admin let(:params) { { format: :json, enterprise_id: enterprise.id } } it "scopes @collection to customers of that enterprise" do - spree_get :index, params + get :index, params expect(assigns(:collection)).to eq [customer] end it "serializes the data" do expect(ActiveModel::ArraySerializer).to receive(:new) - spree_get :index, params + get :index, params end context 'when the customer_balance feature is enabled' do @@ -57,13 +57,13 @@ module Admin expect(customers_with_balance).to receive(:query) { Customer.none } - spree_get :index, params + get :index, params end it 'serializes using CustomerWithBalanceSerializer' do expect(Api::Admin::CustomerWithBalanceSerializer).to receive(:new) - spree_get :index, params + get :index, params end end @@ -75,20 +75,20 @@ module Admin it 'calls Customer.of' do expect(Customer).to receive(:of).twice.with(enterprise) { Customer.none } - spree_get :index, params + get :index, params end it 'serializes calling the UserBalanceCalculator' do expect(OpenFoodNetwork::UserBalanceCalculator) .to receive(:new).with(customer.email, customer.enterprise) { calculator } - spree_get :index, params + get :index, params end end context 'when the customer has no orders' do it 'includes the customer balance in the response' do - spree_get :index, params + get :index, params expect(json_response.first["balance"]).to eq("$0.00") end end @@ -103,7 +103,7 @@ module Admin end it 'includes the customer balance in the response' do - spree_get :index, params + get :index, params expect(json_response.first["balance"]).to eq("$-10.00") end end @@ -124,7 +124,7 @@ module Admin end it 'includes the customer balance in the response' do - spree_get :index, params + get :index, params expect(json_response.first["balance"]).to eq("$10.00") end end @@ -134,7 +134,7 @@ module Admin let!(:line_item) { create(:line_item, order: order, price: 10.0) } it 'includes the customer balance in the response' do - spree_get :index, params + get :index, params expect(json_response.first["balance"]).to eq("$0.00") end end @@ -156,7 +156,7 @@ module Admin it 'includes the customer balance in the response' do expect(order.payment_total).to eq(0) - spree_get :index, params + get :index, params expect(json_response.first["balance"]).to eq('$-10.00') end end @@ -164,7 +164,7 @@ module Admin context "and enterprise_id is not given in params" do it "returns an empty collection" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to eq [] end end @@ -176,7 +176,7 @@ module Admin end it "returns an empty collection" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to eq [] end end @@ -276,7 +276,7 @@ module Admin end it "renders the customer as json" do - spree_get :show, format: :json, id: customer.id + get :show, format: :json, id: customer.id expect(JSON.parse(response.body)["id"]).to eq customer.id end end @@ -287,7 +287,7 @@ module Admin end it "prevents me from updating the customer" do - spree_get :show, format: :json, id: customer.id + get :show, format: :json, id: customer.id expect(response).to redirect_to unauthorized_path end end diff --git a/spec/controllers/admin/enterprises_controller_spec.rb b/spec/controllers/admin/enterprises_controller_spec.rb index a19cada4d4..507f840710 100644 --- a/spec/controllers/admin/enterprises_controller_spec.rb +++ b/spec/controllers/admin/enterprises_controller_spec.rb @@ -457,28 +457,28 @@ describe Admin::EnterprisesController, type: :controller do end context "when no order_cycle or coordinator is provided in params" do - before { spree_get :for_order_cycle, format: :json } + before { get :for_order_cycle, format: :json } it "initializes permissions with nil" do expect(OpenFoodNetwork::OrderCyclePermissions).to have_received(:new).with(user, nil) end end context "when an order_cycle_id is provided in params" do - before { spree_get :for_order_cycle, format: :json, order_cycle_id: 1 } + before { get :for_order_cycle, format: :json, order_cycle_id: 1 } it "initializes permissions with the existing OrderCycle" do expect(OpenFoodNetwork::OrderCyclePermissions).to have_received(:new).with(user, "existing OrderCycle") end end context "when a coordinator is provided in params" do - before { spree_get :for_order_cycle, format: :json, coordinator_id: 1 } + before { get :for_order_cycle, format: :json, coordinator_id: 1 } it "initializes permissions with a new OrderCycle" do expect(OpenFoodNetwork::OrderCyclePermissions).to have_received(:new).with(user, "new OrderCycle") end end context "when both an order cycle and a coordinator are provided in params" do - before { spree_get :for_order_cycle, format: :json, order_cycle_id: 1, coordinator_id: 1 } + before { get :for_order_cycle, format: :json, order_cycle_id: 1, coordinator_id: 1 } it "initializes permissions with the existing OrderCycle" do expect(OpenFoodNetwork::OrderCyclePermissions).to have_received(:new).with(user, "existing OrderCycle") end @@ -500,7 +500,7 @@ describe Admin::EnterprisesController, type: :controller do it "uses permissions to determine which enterprises are visible and should be rendered" do expect(controller).to receive(:render_as_json).with([visible_enterprise], ams_prefix: 'basic', spree_current_user: user).and_call_original - spree_get :visible, format: :json + get :visible, format: :json end end @@ -518,14 +518,14 @@ describe Admin::EnterprisesController, type: :controller do context "html" do it "returns all enterprises" do - spree_get :index, format: :html + get :index, format: :html expect(assigns(:collection)).to include enterprise1, enterprise2, enterprise3 end end context "json" do it "returns all enterprises" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to include enterprise1, enterprise2, enterprise3 end end @@ -543,14 +543,14 @@ describe Admin::EnterprisesController, type: :controller do context "html" do it "returns an empty @collection" do - spree_get :index, format: :html + get :index, format: :html expect(assigns(:collection)).to eq [] end end context "json" do it "scopes @collection to enterprises editable by the user" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to include enterprise1, enterprise2 expect(assigns(:collection)).to_not include enterprise3 end diff --git a/spec/controllers/admin/order_cycles_controller_spec.rb b/spec/controllers/admin/order_cycles_controller_spec.rb index 8321cefaa8..96eba697b0 100644 --- a/spec/controllers/admin/order_cycles_controller_spec.rb +++ b/spec/controllers/admin/order_cycles_controller_spec.rb @@ -20,7 +20,7 @@ module Admin context "html" do it "doesn't load any data" do - spree_get :index, format: :html + get :index, format: :html expect(assigns(:collection)).to be_empty end end @@ -28,7 +28,7 @@ module Admin context "json" do context "where ransack conditions are specified" do it "loads order cycles that closed within the past month, and orders without a close_at date" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to_not include oc1, oc2 expect(assigns(:collection)).to include oc3, oc4 end @@ -38,7 +38,7 @@ module Admin let(:q) { { orders_close_at_gt: 45.days.ago } } it "loads order cycles that closed after the specified date, and orders without a close_at date" do - spree_get :index, format: :json, q: q + get :index, format: :json, q: q expect(assigns(:collection)).to_not include oc1 expect(assigns(:collection)).to include oc2, oc3, oc4 end @@ -47,7 +47,7 @@ module Admin before { q.merge!(id_not_in: [oc2.id, oc4.id]) } it "loads order cycles that meet all conditions" do - spree_get :index, format: :json, q: q + get :index, format: :json, q: q expect(assigns(:collection)).to_not include oc1, oc2, oc4 expect(assigns(:collection)).to include oc3 end @@ -62,7 +62,7 @@ module Admin let!(:distributor) { create(:distributor_enterprise, owner: distributor_owner) } it "renders the new template" do - spree_get :new + get :new expect(response).to render_template :new end end @@ -73,21 +73,21 @@ module Admin let!(:distributor3) { create(:distributor_enterprise) } it "renders the set_coordinator template" do - spree_get :new + get :new expect(response).to render_template :set_coordinator end describe "and a coordinator_id is submitted as part of the request" do describe "when the user manages the enterprise" do it "renders the new template" do - spree_get :new, coordinator_id: distributor1.id + get :new, coordinator_id: distributor1.id expect(response).to render_template :new end end describe "when the user does not manage the enterprise" do it "renders the set_coordinator template and sets a flash error" do - spree_get :new, coordinator_id: distributor3.id + get :new, coordinator_id: distributor3.id expect(response).to render_template :set_coordinator expect(flash[:error]).to eq "You don't have permission to create an order cycle coordinated by that enterprise" end @@ -331,7 +331,7 @@ module Admin describe "when an order cycle is deleteable" do it "allows the order_cycle to be destroyed" do - spree_get :destroy, id: oc.id + get :destroy, id: oc.id expect(OrderCycle.find_by(id: oc.id)).to be nil end end @@ -340,7 +340,7 @@ module Admin let!(:order) { create(:order, order_cycle: oc) } it "displays an error message when we attempt to delete it" do - spree_get :destroy, id: oc.id + get :destroy, id: oc.id expect(response).to redirect_to admin_order_cycles_path expect(flash[:error]).to eq I18n.t('admin.order_cycles.destroy_errors.orders_present') end @@ -350,7 +350,7 @@ module Admin let!(:schedule) { create(:schedule, order_cycles: [oc]) } it "displays an error message when we attempt to delete it" do - spree_get :destroy, id: oc.id + get :destroy, id: oc.id expect(response).to redirect_to admin_order_cycles_path expect(flash[:error]).to eq I18n.t('admin.order_cycles.destroy_errors.schedule_present') end diff --git a/spec/controllers/admin/proxy_orders_controller_spec.rb b/spec/controllers/admin/proxy_orders_controller_spec.rb index 46436dedda..d98eccabeb 100644 --- a/spec/controllers/admin/proxy_orders_controller_spec.rb +++ b/spec/controllers/admin/proxy_orders_controller_spec.rb @@ -42,7 +42,7 @@ describe Admin::ProxyOrdersController, type: :controller do context "when cancellation succeeds" do it 'renders the cancelled proxy_order as json' do - spree_get :cancel, params + get :cancel, params json_response = JSON.parse(response.body) expect(json_response['state']).to eq "canceled" expect(json_response['id']).to eq proxy_order.id @@ -54,7 +54,7 @@ describe Admin::ProxyOrdersController, type: :controller do before { order_cycle.update(orders_close_at: 1.day.ago) } it "shows an error" do - spree_get :cancel, params + get :cancel, params json_response = JSON.parse(response.body) expect(json_response['errors']).to eq ['Could not cancel the order'] end @@ -111,7 +111,7 @@ describe Admin::ProxyOrdersController, type: :controller do context "when resuming succeeds" do it 'renders the resumed proxy_order as json' do - spree_get :resume, params + get :resume, params json_response = JSON.parse(response.body) expect(json_response['state']).to eq "resumed" expect(json_response['id']).to eq proxy_order.id @@ -123,7 +123,7 @@ describe Admin::ProxyOrdersController, type: :controller do before { order_cycle.update(orders_close_at: 1.day.ago) } it "shows an error" do - spree_get :resume, params + get :resume, params json_response = JSON.parse(response.body) expect(json_response['errors']).to eq ['Could not resume the order'] end diff --git a/spec/controllers/admin/schedules_controller_spec.rb b/spec/controllers/admin/schedules_controller_spec.rb index 4013f7492b..e6981bcfe6 100644 --- a/spec/controllers/admin/schedules_controller_spec.rb +++ b/spec/controllers/admin/schedules_controller_spec.rb @@ -21,13 +21,13 @@ describe Admin::SchedulesController, type: :controller do let(:params) { { format: :json } } it "scopes @collection to schedules containing order_cycles coordinated by enterprises I manage" do - spree_get :index, params + get :index, params expect(assigns(:collection)).to eq [coordinated_schedule] end it "serializes the data" do expect(ActiveModel::ArraySerializer).to receive(:new) - spree_get :index, params + get :index, params end context "and there is a schedule of an OC coordinated by _another_ enterprise I manage and the first enterprise is given" do @@ -37,7 +37,7 @@ describe Admin::SchedulesController, type: :controller do let(:params) { { format: :json, enterprise_id: managed_coordinator.id } } it "scopes @collection to schedules containing order_cycles coordinated by the first enterprise" do - spree_get :index, params + get :index, params expect(assigns(:collection)).to eq [coordinated_schedule] end end @@ -45,7 +45,7 @@ describe Admin::SchedulesController, type: :controller do context "where I dont manage an order cycle coordinator" do it "returns an empty collection" do - spree_get :index, format: :json + get :index, format: :json expect(assigns(:collection)).to be_nil end end diff --git a/spec/controllers/admin/stripe_accounts_controller_spec.rb b/spec/controllers/admin/stripe_accounts_controller_spec.rb index 3517374885..3774c47921 100644 --- a/spec/controllers/admin/stripe_accounts_controller_spec.rb +++ b/spec/controllers/admin/stripe_accounts_controller_spec.rb @@ -15,7 +15,7 @@ describe Admin::StripeAccountsController, type: :controller do end it "redirects to Stripe Authorization url constructed OAuth" do - spree_get :connect, enterprise_id: 1 # A deterministic id results in a deterministic state JWT token + get :connect, enterprise_id: 1 # A deterministic id results in a deterministic state JWT token expect(response).to redirect_to("https://connect.stripe.com/oauth/authorize?state=eyJhbGciOiJIUzI1NiJ9.eyJlbnRlcnByaXNlX2lkIjoiMSJ9.jSSFGn0bLhwuiQYK5ORmHWW7aay1l030bcfGwn1JbFg&scope=read_write&client_id=some_id&response_type=code") end @@ -98,7 +98,7 @@ describe Admin::StripeAccountsController, type: :controller do end it "redirects to unauthorized" do - spree_get :status, params + get :status, params expect(response).to redirect_to unauthorized_path end end @@ -110,7 +110,7 @@ describe Admin::StripeAccountsController, type: :controller do context "when Stripe is not enabled" do it "returns with a status of 'stripe_disabled'" do - spree_get :status, params + get :status, params json_response = JSON.parse(response.body) expect(json_response["status"]).to eq "stripe_disabled" end @@ -121,7 +121,7 @@ describe Admin::StripeAccountsController, type: :controller do context "when no stripe account is associated with the specified enterprise" do it "returns with a status of 'account_missing'" do - spree_get :status, params + get :status, params json_response = JSON.parse(response.body) expect(json_response["status"]).to eq "account_missing" end @@ -136,7 +136,7 @@ describe Admin::StripeAccountsController, type: :controller do end it "returns with a status of 'access_revoked'" do - spree_get :status, params + get :status, params json_response = JSON.parse(response.body) expect(json_response["status"]).to eq "access_revoked" end @@ -157,7 +157,7 @@ describe Admin::StripeAccountsController, type: :controller do end it "returns with a status of 'connected'" do - spree_get :status, params + get :status, params json_response = JSON.parse(response.body) expect(json_response["status"]).to eq "connected" # serializes required attrs diff --git a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb index a64bac75ba..c676cd002a 100644 --- a/spec/controllers/admin/stripe_connect_settings_controller_spec.rb +++ b/spec/controllers/admin/stripe_connect_settings_controller_spec.rb @@ -17,7 +17,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do before { allow(controller).to receive(:spree_current_user) { user } } it "does not allow access" do - spree_get :edit + get :edit expect(response).to redirect_to unauthorized_path end end @@ -34,7 +34,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do end it "sets the account status to :empty_api_key_error_html" do - spree_get :edit + get :edit expect(assigns(:stripe_account)[:status]).to eq :empty_api_key_error_html expect(assigns(:settings).stripe_connect_enabled).to be true end @@ -52,7 +52,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do end it "sets the account status to :auth_fail_error" do - spree_get :edit + get :edit expect(assigns(:stripe_account)[:status]).to eq :auth_fail_error expect(assigns(:settings).stripe_connect_enabled).to be true end @@ -65,7 +65,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do end it "sets the account status to :ok, loads settings into Struct" do - spree_get :edit + get :edit expect(assigns(:stripe_account)[:status]).to eq :ok expect(assigns(:obfuscated_secret_key)).to eq "sk_test_****xxxx" expect(assigns(:settings).stripe_connect_enabled).to be true @@ -82,7 +82,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do before { allow(controller).to receive(:spree_current_user) { user } } it "does not allow access" do - spree_get :update, params + get :update, params expect(response).to redirect_to unauthorized_path end end @@ -95,7 +95,7 @@ describe Admin::StripeConnectSettingsController, type: :controller do it "sets global config to the specified values" do expect(Spree::Config.stripe_connect_enabled).to be true - spree_get :update, params + get :update, params expect(Spree::Config.stripe_connect_enabled).to be false end end diff --git a/spec/controllers/admin/subscriptions_controller_spec.rb b/spec/controllers/admin/subscriptions_controller_spec.rb index 4ef466f3e1..65a8cde0c3 100644 --- a/spec/controllers/admin/subscriptions_controller_spec.rb +++ b/spec/controllers/admin/subscriptions_controller_spec.rb @@ -19,7 +19,7 @@ describe Admin::SubscriptionsController, type: :controller do context 'as a regular user' do it 'redirects to unauthorized' do - spree_get :index, params + get :index, params expect(response).to redirect_to unauthorized_path end end @@ -32,7 +32,7 @@ describe Admin::SubscriptionsController, type: :controller do let!(:subscription) { create(:subscription, shop: shop) } it 'renders the index page with appropriate data' do - spree_get :index, params + get :index, params expect(response).to render_template 'index' expect(assigns(:collection)).to eq [] # No collection loaded expect(assigns(:shops)).to eq [shop] # Shops are loaded @@ -41,7 +41,7 @@ describe Admin::SubscriptionsController, type: :controller do context "where I don't manage a shop that is set up for subscriptions" do it 'renders the setup_explanation page' do - spree_get :index, params + get :index, params expect(response).to render_template 'setup_explanation' expect(assigns(:collection)).to eq [] # No collection loaded expect(assigns(:shop)).to eq shop # First SO enabled shop is loaded @@ -56,7 +56,7 @@ describe Admin::SubscriptionsController, type: :controller do context 'as a regular user' do it 'redirects to unauthorized' do - spree_get :index, params + get :index, params expect(response).to redirect_to unauthorized_path end end @@ -67,7 +67,7 @@ describe Admin::SubscriptionsController, type: :controller do let!(:subscription2) { create(:subscription, shop: shop2) } it 'renders the collection as json' do - spree_get :index, params + get :index, params json_response = JSON.parse(response.body) expect(json_response.count).to be 2 expect(json_response.map{ |so| so['id'] }).to include subscription.id, subscription2.id @@ -77,7 +77,7 @@ describe Admin::SubscriptionsController, type: :controller do before { params.merge!(q: { shop_id_eq: shop2.id }) } it "restricts the list of subscriptions" do - spree_get :index, params + get :index, params json_response = JSON.parse(response.body) expect(json_response.count).to be 1 ids = json_response.map{ |so| so['id'] } @@ -99,7 +99,7 @@ describe Admin::SubscriptionsController, type: :controller do it 'loads the preloads the necessary data' do expect(controller).to receive(:load_form_data) - spree_get :new, subscription: { shop_id: shop.id } + get :new, subscription: { shop_id: shop.id } expect(assigns(:subscription)).to be_a_new Subscription expect(assigns(:subscription).shop).to eq shop end @@ -238,7 +238,7 @@ describe Admin::SubscriptionsController, type: :controller do it 'loads the preloads the necessary data' do expect(controller).to receive(:load_form_data) - spree_get :edit, id: subscription.id + get :edit, id: subscription.id expect(assigns(:subscription)).to eq subscription end end diff --git a/spec/controllers/api/customers_controller_spec.rb b/spec/controllers/api/customers_controller_spec.rb index c40f04dac7..2034d3118e 100644 --- a/spec/controllers/api/customers_controller_spec.rb +++ b/spec/controllers/api/customers_controller_spec.rb @@ -19,7 +19,7 @@ module Api end it "lists customers associated with the current user" do - spree_get :index + get :index expect(response.status).to eq 200 expect(json_response.length).to eq 1 expect(json_response.first[:id]).to eq customer1.id diff --git a/spec/controllers/api/exchange_products_controller_spec.rb b/spec/controllers/api/exchange_products_controller_spec.rb index 3fa7248198..d9aa7ce55c 100644 --- a/spec/controllers/api/exchange_products_controller_spec.rb +++ b/spec/controllers/api/exchange_products_controller_spec.rb @@ -26,7 +26,7 @@ module Api let(:products_relation) { Spree::Product.where("1=0") } it "handles it gracefully" do - spree_get :index, exchange_id: exchange.id + get :index, exchange_id: exchange.id expect(json_response["products"].length).to eq 0 end end @@ -36,7 +36,7 @@ module Api describe "when an exchange id param is provided" do it "uses exchange order_cycle, incoming and enterprise to fetch products" do - spree_get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false + get :index, exchange_id: exchange.id, order_cycle_id: 666, enterprise_id: 666, incoming: false expect(json_response["products"].first["supplier_name"]).to eq exchange.variants.first.product.supplier.name end end @@ -59,7 +59,7 @@ module Api describe "when a specific page is requested" do it "returns the requested page with paginated data" do - spree_get :index, exchange_id: exchange.id, page: 1 + get :index, exchange_id: exchange.id, page: 1 expect(json_response["products"].size).to eq 1 expect(json_response["pagination"]["results"]).to eq 2 @@ -69,7 +69,7 @@ module Api describe "when no specific page is requested" do it "returns all results without paginating" do - spree_get :index, exchange_id: exchange.id + get :index, exchange_id: exchange.id expect(json_response["products"].size).to eq 2 expect(json_response["pagination"]).to be nil diff --git a/spec/controllers/api/shops_controller_spec.rb b/spec/controllers/api/shops_controller_spec.rb index 08040feea8..22b40b22db 100644 --- a/spec/controllers/api/shops_controller_spec.rb +++ b/spec/controllers/api/shops_controller_spec.rb @@ -23,7 +23,7 @@ describe Api::ShopsController, type: :controller do describe "#show" do it "returns shopfront data for an enterprise" do - spree_get :show, id: producer.id + get :show, id: producer.id expect(json_response['name']).to eq 'Shopfront Test Producer' expect(json_response['hubs'][0]['name']).to eq 'Shopfront Test Hub' @@ -33,7 +33,7 @@ describe Api::ShopsController, type: :controller do describe "#closed_shops" do it "returns data for all closed shops" do - spree_get :closed_shops, {} + get :closed_shops, {} expect(json_response).not_to match hub.name diff --git a/spec/controllers/api/statuses_controller_spec.rb b/spec/controllers/api/statuses_controller_spec.rb index b36f7511e3..40132eed5c 100644 --- a/spec/controllers/api/statuses_controller_spec.rb +++ b/spec/controllers/api/statuses_controller_spec.rb @@ -9,21 +9,21 @@ module Api describe "job queue status" do it "returns alive when up to date" do Spree::Config.last_job_queue_heartbeat_at = Time.now.in_time_zone - spree_get :job_queue + get :job_queue expect(response).to be_success expect(response.body).to eq({ alive: true }.to_json) end it "returns dead otherwise" do Spree::Config.last_job_queue_heartbeat_at = 10.minutes.ago - spree_get :job_queue + get :job_queue expect(response).to be_success expect(response.body).to eq({ alive: false }.to_json) end it "returns dead when no heartbeat recorded" do Spree::Config.last_job_queue_heartbeat_at = nil - spree_get :job_queue + get :job_queue expect(response).to be_success expect(response.body).to eq({ alive: false }.to_json) end diff --git a/spec/controllers/api/variants_controller_spec.rb b/spec/controllers/api/variants_controller_spec.rb index 6720461c56..4a26422b62 100644 --- a/spec/controllers/api/variants_controller_spec.rb +++ b/spec/controllers/api/variants_controller_spec.rb @@ -26,7 +26,7 @@ describe Api::VariantsController, type: :controller do end it "retrieves a list of variants with appropriate attributes" do - spree_get :index, format: :json + get :index, format: :json keys = json_response.first.keys.map(&:to_sym) expect(attributes.all?{ |attr| keys.include? attr }).to eq(true) diff --git a/spec/controllers/enterprises_controller_spec.rb b/spec/controllers/enterprises_controller_spec.rb index 68ce5a8010..86ff995516 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 - spree_get :shop, id: distributor + get :shop, 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 - spree_get :shop, id: distributor + get :shop, 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') - spree_get :shop, id: distributor + get :shop, 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') - spree_get :shop, id: distributor + get :shop, 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') - spree_get :shop, id: distributor + get :shop, id: distributor expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2, order_cycle3 allow(controller).to receive(:spree_current_user) { user } - spree_get :shop, id: distributor + get :shop, id: distributor expect(assigns(:order_cycles)).to include order_cycle1, order_cycle2, order_cycle3 oc3_exchange.update_attribute(:tag_list, "wholesale") - spree_get :shop, id: distributor + get :shop, 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"]) - spree_get :shop, id: distributor + get :shop, 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 - spree_get :shop, id: distributor + get :shop, 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 - spree_get :shop, id: current_distributor + get :shop, 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 - spree_get :shop, id: current_distributor + get :shop, 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 - spree_get :shop, id: distributor + get :shop, 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 - spree_get :shop, id: distributor + get :shop, id: distributor expect(controller.current_order.distributor).to eq(distributor) expect(controller.current_order.order_cycle).to eq(order_cycle1) @@ -155,7 +155,7 @@ describe EnterprisesController, type: :controller do end it "responds with status of 409 when the permalink matches an existing route" do - # spree_get :check_permalink, { permalink: 'enterprise_permalink', format: :js } + # get :check_permalink, { permalink: 'enterprise_permalink', format: :js } # expect(response.status).to be 409 xhr :get, :check_permalink, permalink: 'map', format: :js expect(response.status).to be 409 @@ -166,7 +166,7 @@ describe EnterprisesController, type: :controller do context "checking access on nonexistent enterprise" do before do - spree_get :shop, id: "some_nonexistent_enterprise" + get :shop, id: "some_nonexistent_enterprise" end it "redirects to shops_path" do diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index bbcce1bf33..6988be63a9 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -8,7 +8,7 @@ describe ShopController, type: :controller do let(:distributor) { create(:distributor_enterprise, payment_methods: [pm], shipping_methods: [sm]) } it "redirects to the home page if no distributor is selected" do - spree_get :show + get :show expect(response).to redirect_to root_path end @@ -20,14 +20,14 @@ describe ShopController, type: :controller do describe "selecting an order cycle" do it "should select an order cycle when only one order cycle is open" do oc1 = create(:simple_order_cycle, distributors: [distributor]) - spree_get :show + get :show expect(controller.current_order_cycle).to eq(oc1) end it "should not set an order cycle when multiple order cycles are open" do oc1 = create(:simple_order_cycle, distributors: [distributor]) oc2 = create(:simple_order_cycle, distributors: [distributor]) - spree_get :show + get :show expect(controller.current_order_cycle).to be_nil end @@ -55,7 +55,7 @@ describe ShopController, type: :controller do it "should return the current order cycle when hit with GET" do oc1 = create(:simple_order_cycle, distributors: [distributor]) allow(controller).to receive(:current_order_cycle).and_return oc1 - spree_get :order_cycle + get :order_cycle expect(response.body).to have_content oc1.id end