mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
Fix rspec syntax
This commit is contained in:
@@ -19,7 +19,7 @@ describe Admin::SubscriptionsController, type: :controller do
|
||||
|
||||
context 'as a regular user' do
|
||||
it 'redirects to unauthorized' do
|
||||
get :index, params
|
||||
get :index, params: 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
|
||||
get :index, params
|
||||
get :index, params: 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
|
||||
get :index, params
|
||||
get :index, params: 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
|
||||
get :index, params
|
||||
get :index, params: 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
|
||||
get :index, params
|
||||
get :index, params: 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
|
||||
get :index, params
|
||||
get :index, params: 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)
|
||||
get :new, subscription: { shop_id: shop.id }
|
||||
get :new, params: { 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)
|
||||
get :edit, id: subscription.id
|
||||
get :edit, params: { id: subscription.id }
|
||||
expect(assigns(:subscription)).to eq subscription
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
end
|
||||
|
||||
it "redirects to unauthorized" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -33,7 +33,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
|
||||
context "but the producer has not granted VO permission" do
|
||||
it "redirects to unauthorized" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
other_variant_override = create(:variant_override, hub: hub, variant: create(:variant))
|
||||
expect(controller).not_to receive(:authorize!).with(:update, other_variant_override)
|
||||
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,7 +51,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
end
|
||||
|
||||
it "loads data" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
expect(assigns[:hubs]).to eq [hub]
|
||||
expect(assigns[:producers]).to eq [variant.product.supplier]
|
||||
expect(assigns[:hub_permissions]).to eq Hash[hub.id, [variant.product.supplier.id]]
|
||||
@@ -59,7 +59,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
end
|
||||
|
||||
it "allows me to update the variant override" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
|
||||
variant_override.reload
|
||||
expect(variant_override.price).to eq 123.45
|
||||
@@ -72,7 +72,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
let(:variant_override_params) { [{ id: variant_override.id, price: "", count_on_hand: "", default_stock: nil, resettable: nil, sku: nil, on_demand: nil }] }
|
||||
|
||||
it "destroys the variant override" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
expect(VariantOverride.find_by(id: variant_override.id)).to be_nil
|
||||
end
|
||||
end
|
||||
@@ -84,7 +84,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
before { deleted_variant.update_attribute :deleted_at, Time.zone.now }
|
||||
|
||||
it "allows to update other variant overrides" do
|
||||
put :bulk_update, format: format, variant_overrides: variant_override_params
|
||||
put :bulk_update, as: format, params: { variant_overrides: variant_override_params }
|
||||
|
||||
expect(response).to_not redirect_to unauthorized_path
|
||||
variant_override.reload
|
||||
@@ -118,7 +118,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
end
|
||||
|
||||
it "redirects to unauthorized" do
|
||||
put :bulk_reset, params
|
||||
put :bulk_reset, params: params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -130,7 +130,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
|
||||
context "where the producer has not granted create_variant_overrides permission to the hub" do
|
||||
it "restricts access" do
|
||||
put :bulk_reset, params
|
||||
put :bulk_reset, params: params
|
||||
expect(response).to redirect_to unauthorized_path
|
||||
end
|
||||
end
|
||||
@@ -139,7 +139,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
let!(:er1) { create(:enterprise_relationship, parent: producer, child: hub, permissions_list: [:create_variant_overrides]) }
|
||||
|
||||
it "loads data" do
|
||||
put :bulk_reset, params
|
||||
put :bulk_reset, params: params
|
||||
expect(assigns[:hubs]).to eq [hub]
|
||||
expect(assigns[:producers]).to eq [producer]
|
||||
expect(assigns[:hub_permissions]).to eq Hash[hub.id, [producer.id]]
|
||||
@@ -149,7 +149,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
it "updates stock to default values where reset is enabled" do
|
||||
expect(variant_override1.reload.count_on_hand).to eq 5 # reset enabled
|
||||
expect(variant_override2.reload.count_on_hand).to eq 2 # reset disabled
|
||||
put :bulk_reset, params
|
||||
put :bulk_reset, params: params
|
||||
expect(variant_override1.reload.count_on_hand).to eq 7 # reset enabled
|
||||
expect(variant_override2.reload.count_on_hand).to eq 2 # reset disabled
|
||||
end
|
||||
@@ -164,7 +164,7 @@ describe Admin::VariantOverridesController, type: :controller do
|
||||
|
||||
it "does not reset count_on_hand for variant_overrides not in params" do
|
||||
expect {
|
||||
put :bulk_reset, params
|
||||
put :bulk_reset, params: params
|
||||
}.to_not change{ variant_override3.reload.count_on_hand }
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user