mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-03 02:21:33 +00:00
29 lines
605 B
Ruby
29 lines
605 B
Ruby
require 'spec_helper'
|
|
|
|
describe Spree::Product do
|
|
|
|
describe "associations" do
|
|
it { should belong_to(:supplier) }
|
|
it { should have_and_belong_to_many(:distributors) }
|
|
end
|
|
|
|
describe "validations" do
|
|
it "is valid when created from factory" do
|
|
build(:product).should be_valid
|
|
end
|
|
|
|
it "requires a supplier" do
|
|
product = build(:product)
|
|
product.supplier = nil
|
|
product.should_not be_valid
|
|
end
|
|
|
|
it "requires at least one distributor" do
|
|
product = build(:product)
|
|
product.distributors.clear
|
|
product.should_not be_valid
|
|
end
|
|
end
|
|
|
|
end
|