Replace spree_get with simple call to get

This commit is contained in:
Luis Ramos
2021-01-22 22:30:11 +00:00
parent 94275eedfb
commit d6a53cb84f
4 changed files with 28 additions and 28 deletions

View File

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

View File

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

View File

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

View File

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