mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Move model spec into validations block
This commit is contained in:
@@ -9,28 +9,6 @@ module Spree
|
||||
it { should have_many(:product_distributions) }
|
||||
end
|
||||
|
||||
describe "validating tax category" do
|
||||
context "when a tax category is required" do
|
||||
before { Spree::Config.products_require_tax_category = true }
|
||||
|
||||
it "is invalid when a tax category is not provided" do
|
||||
product = create(:product)
|
||||
product.tax_category_id = nil
|
||||
product.should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "when a tax category is not required" do
|
||||
before { Spree::Config.products_require_tax_category = false }
|
||||
|
||||
it "is valid when a tax category is not provided" do
|
||||
product = create(:product)
|
||||
product.tax_category_id = nil
|
||||
product.should be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "validations and defaults" do
|
||||
it "is valid when created from factory" do
|
||||
create(:product).should be_valid
|
||||
@@ -63,6 +41,29 @@ module Spree
|
||||
product.available_on.should == Time.now
|
||||
end
|
||||
|
||||
describe "tax category" do
|
||||
context "when a tax category is required" do
|
||||
before { Spree::Config.products_require_tax_category = true }
|
||||
|
||||
it "is invalid when a tax category is not provided" do
|
||||
product = create(:product)
|
||||
product.tax_category_id = nil
|
||||
product.should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
context "when a tax category is not required" do
|
||||
before { Spree::Config.products_require_tax_category = false }
|
||||
|
||||
it "is valid when a tax category is not provided" do
|
||||
product = create(:product)
|
||||
product.tax_category_id = nil
|
||||
product.should be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
context "when the product has variants" do
|
||||
let(:product) do
|
||||
product = create(:simple_product)
|
||||
|
||||
Reference in New Issue
Block a user