Remove unnecessary spec helper

Best viewed ignoring whitespaces.

Products don't require a tax category by default. And when you activate
it via Spree::Config then it's automatically reset at the end of the spec.
We don't need this helper to do it.
This commit is contained in:
Maikel Linke
2024-01-12 17:12:40 +11:00
parent 95c6a56e2e
commit c5b64e875f
2 changed files with 19 additions and 30 deletions

View File

@@ -2,15 +2,6 @@
module OpenFoodNetwork
module ProductsHelper
def with_products_require_tax_category(value)
original_value = Spree::Config.products_require_tax_category
Spree::Config.products_require_tax_category = value
yield
ensure
Spree::Config.products_require_tax_category = original_value
end
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!" }

View File

@@ -356,32 +356,30 @@ describe '
context "products do not require a tax category" do
it "creating a new product" do
with_products_require_tax_category(false) do
visit spree.admin_products_path
click_link 'New Product'
visit spree.admin_products_path
click_link 'New Product'
fill_in 'product_name', with: 'A new product !!!'
fill_in 'product_price', with: '19.99'
fill_in 'product_name', with: 'A new product !!!'
fill_in 'product_price', with: '19.99'
expect(page).to have_selector('#product_supplier_id')
select 'Another Supplier', from: 'product_supplier_id'
select 'Weight (g)', from: 'product_variant_unit_with_scale'
fill_in 'product_unit_value', with: '500'
select taxon.name, from: "product_primary_taxon_id"
select 'None', from: "product_tax_category_id"
expect(page).to have_selector('#product_supplier_id')
select 'Another Supplier', from: 'product_supplier_id'
select 'Weight (g)', from: 'product_variant_unit_with_scale'
fill_in 'product_unit_value', with: '500'
select taxon.name, from: "product_primary_taxon_id"
select 'None', from: "product_tax_category_id"
# Should only have suppliers listed which the user can manage
expect(page).to have_select 'product_supplier_id',
with_options: [@supplier2.name, @supplier_permitted.name]
expect(page).not_to have_select 'product_supplier_id', with_options: [@supplier.name]
# Should only have suppliers listed which the user can manage
expect(page).to have_select 'product_supplier_id',
with_options: [@supplier2.name, @supplier_permitted.name]
expect(page).not_to have_select 'product_supplier_id', with_options: [@supplier.name]
click_button 'Create'
click_button 'Create'
expect(flash_message).to eq('Product "A new product !!!" has been successfully created!')
product = Spree::Product.find_by(name: 'A new product !!!')
expect(product.supplier).to eq(@supplier2)
expect(product.variants.first.tax_category).to be_nil
end
expect(flash_message).to eq('Product "A new product !!!" has been successfully created!')
product = Spree::Product.find_by(name: 'A new product !!!')
expect(product.supplier).to eq(@supplier2)
expect(product.variants.first.tax_category).to be_nil
end
end