Do not use with_products_require_tax_category in around filters - Spree::Config has caching which isn't shared between contexts

This commit is contained in:
Rohan Mitchell
2015-06-24 14:52:17 +10:00
parent bc11140a40
commit d9f4a92648
2 changed files with 26 additions and 26 deletions

View File

@@ -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

View File

@@ -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