mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Product requires at least one distributor
This commit is contained in:
@@ -3,4 +3,6 @@ Spree::Product.class_eval do
|
||||
has_and_belongs_to_many :distributors
|
||||
|
||||
attr_accessible :supplier_id
|
||||
|
||||
validates_presence_of :distributors
|
||||
end
|
||||
|
||||
@@ -7,4 +7,16 @@ describe Spree::Product do
|
||||
it { should have_and_belong_to_many(:distributors) }
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
it "is valid when created from factory" do
|
||||
Spree::Product.make.should be_valid
|
||||
end
|
||||
|
||||
it "requires at least one distributor" do
|
||||
product = Spree::Product.make
|
||||
product.distributors.clear
|
||||
product.should_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -35,6 +35,7 @@ Spree::Product.blueprint do
|
||||
available_on{ Date.today - 2.days }
|
||||
count_on_hand { 5 }
|
||||
price { 10.99 }
|
||||
distributors{[Spree::Distributor.first || Spree::Distributor.make]}
|
||||
end
|
||||
|
||||
Spree::Variant.blueprint do
|
||||
|
||||
Reference in New Issue
Block a user