mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user