diff --git a/spec/features/admin/products_spec.rb b/spec/features/admin/products_spec.rb index eb8da43930..59748091b3 100644 --- a/spec/features/admin/products_spec.rb +++ b/spec/features/admin/products_spec.rb @@ -118,32 +118,32 @@ feature %q{ end context "products do not require a tax category" do - around { |example| with_products_require_tax_category(false) { example.run } } - scenario "creating a new product", js: true do - click_link 'Products' - click_link 'New Product' + with_products_require_tax_category(false) do + click_link 'Products' + 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' - page.should 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_description', with: '500' - select taxon.name, from: "product_primary_taxon_id" - select 'None', from: "product_tax_category_id" + page.should 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_description', 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 - page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name] - page.should_not have_select 'product_supplier_id', with_options: [@supplier.name] + # Should only have suppliers listed which the user can manage + page.should have_select 'product_supplier_id', with_options: [@supplier2.name, @supplier_permitted.name] + page.should_not have_select 'product_supplier_id', with_options: [@supplier.name] - click_button 'Create' + click_button 'Create' - flash_message.should == 'Product "A new product !!!" has been successfully created!' - product = Spree::Product.find_by_name('A new product !!!') - product.supplier.should == @supplier2 - product.tax_category.should be_nil + flash_message.should == 'Product "A new product !!!" has been successfully created!' + product = Spree::Product.find_by_name('A new product !!!') + product.supplier.should == @supplier2 + product.tax_category.should be_nil + end end end diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index dfaf715b35..6a4825bcef 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -40,18 +40,18 @@ module Spree describe "tax category" do context "when a tax category is required" do - around { |example| with_products_require_tax_category(true) { example.run } } - it "is invalid when a tax category is not provided" do - build(:product, tax_category_id: nil).should_not be_valid + with_products_require_tax_category(true) do + build(:product, tax_category_id: nil).should_not be_valid + end end end context "when a tax category is not required" do - around { |example| with_products_require_tax_category(false) { example.run } } - it "is valid when a tax category is not provided" do - build(:product, tax_category_id: nil).should be_valid + with_products_require_tax_category(false) do + build(:product, tax_category_id: nil).should be_valid + end end end end