Move model spec into validations block

This commit is contained in:
Rohan Mitchell
2015-01-08 09:37:35 +11:00
parent a9b91bc52a
commit e4efda2f96

View File

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