From e4efda2f961e6f5e1201052f1a617e4dbb804526 Mon Sep 17 00:00:00 2001 From: Rohan Mitchell Date: Thu, 8 Jan 2015 09:37:35 +1100 Subject: [PATCH] Move model spec into validations block --- spec/models/spree/product_spec.rb | 45 ++++++++++++++++--------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/spec/models/spree/product_spec.rb b/spec/models/spree/product_spec.rb index 2a399ba30e..3e4999556d 100644 --- a/spec/models/spree/product_spec.rb +++ b/spec/models/spree/product_spec.rb @@ -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)