From c5b64e875fffa874e6692b3a90cbe6210514aba6 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 12 Jan 2024 17:12:40 +1100 Subject: [PATCH] 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. --- spec/support/products_helper.rb | 9 ------- spec/system/admin/products_spec.rb | 40 ++++++++++++++---------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/spec/support/products_helper.rb b/spec/support/products_helper.rb index 1a865f3fd4..3fcc9e4143 100644 --- a/spec/support/products_helper.rb +++ b/spec/support/products_helper.rb @@ -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!" } diff --git a/spec/system/admin/products_spec.rb b/spec/system/admin/products_spec.rb index 0a83938ce0..12f1cddee5 100644 --- a/spec/system/admin/products_spec.rb +++ b/spec/system/admin/products_spec.rb @@ -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