Sha256: 3438fa6c86baab3e3ed8cb93d7ab7b75a503a3186d14bf947b7cd0d308ea0a8d
Contents?: true
Size: 930 Bytes
Versions: 2
Compression:
Stored size: 930 Bytes
Contents
require 'spec_helper' describe Spree::Favorite do it { should allow_mass_assignment_of :product_id } it { should belong_to(:product) } it { should belong_to(:user) } it { should validate_uniqueness_of(:product_id).scoped_to(:user_id).with_message("already marked as favorite") } it { should validate_presence_of(:user_id) } it { should validate_presence_of(:product_id) } context "when product_id is present" do before(:each) do @favorite = Spree::Favorite.new :product_id => 'invalid product id' end it "checks for the presence of product" do @favorite.valid? @favorite.errors[:product].should eq(["is invalid"]) end end context "when product_id is not present" do before(:each) do @favorite = Spree::Favorite.new end it "does not validate the presence of product" do @favorite.valid? @favorite.errors[:product].should eq([]) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spree_favorite_products-1.0.1 | spec/models/spree/favorite_spec.rb |
spree_favorite_products-1.0.0 | spec/models/spree/favorite_spec.rb |