Remove unnecessary spec helper module

These shared examples were used in only one spec file. It's much easier
to read having all the related specs in one file instead of hiding some
in a helper module.

It's also one less file to load whenever we run specs.
This commit is contained in:
Maikel Linke
2024-01-12 17:18:07 +11:00
parent c5b64e875f
commit ad26a006e2
3 changed files with 14 additions and 24 deletions

View File

@@ -231,7 +231,6 @@ RSpec.configure do |config|
config.include PreferencesHelper
config.include OpenFoodNetwork::FiltersHelper
config.include OpenFoodNetwork::EnterpriseGroupsHelper
config.include OpenFoodNetwork::ProductsHelper
config.include OpenFoodNetwork::DistributionHelper
config.include OpenFoodNetwork::HtmlHelper
config.include ActionView::Helpers::DateHelper

View File

@@ -52,7 +52,20 @@ describe Api::V0::ProductsController, type: :controller do
expect(response.status).to eq(404)
end
include_examples "modifying product actions are restricted"
it "cannot create a new product if not an admin" do
api_post :create, product: { name: "Brand new product!" }
assert_unauthorized!
end
it "cannot update a product" do
api_put :update, id: product.to_param, product: { name: "I hacked your store!" }
assert_unauthorized!
end
it "cannot delete a product" do
api_delete :destroy, id: product.to_param
assert_unauthorized!
end
end
context "as an enterprise user" do

View File

@@ -1,22 +0,0 @@
# frozen_string_literal: true
module OpenFoodNetwork
module ProductsHelper
shared_examples "modifying product actions are restricted" do
it "cannot create a new product if not an admin" do
api_post :create, product: { name: "Brand new product!" }
assert_unauthorized!
end
it "cannot update a product" do
api_put :update, id: product.to_param, product: { name: "I hacked your store!" }
assert_unauthorized!
end
it "cannot delete a product" do
api_delete :destroy, id: product.to_param
assert_unauthorized!
end
end
end
end