Sha256: 65d65d139c89b54f9d548debe2a4d6647b2710599ae74ddc5962f7764edfde49
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
require 'spec_helper' describe Spree::User do before(:each) do @user = Spree::User.create! email: 'test@example.com', password: 'spree123' shipping_category = Spree::ShippingCategory.create! name: 'shipping_category' @product1 = Spree::Product.create! name: 'product1', price: 100, shipping_category_id: shipping_category.id @product2 = Spree::Product.create! name: 'product2', price: 100, shipping_category_id: shipping_category.id favorite = Spree::Favorite.new favorite.product_id = @product1.id favorite.user_id = @user.id favorite.save! end it { is_expected.to have_many(:favorites).dependent(:destroy) } it { is_expected.to have_many(:favorite_products).through(:favorites).class_name('Spree::Product') } describe "has_favorite_product?" do context "when product in user's favorite products" do it { expect(@user.has_favorite_product?(@product1.id)).to be_truthy } end context 'when product is not in users favorite products' do it { expect(@user.has_favorite_product?(@product2.id)).to be_falsey } end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
spree_favorite_products-3.2.0 | spec/models/spree/user_decorator_spec.rb |
solidus_favorite_products-2.1.1 | spec/models/spree/user_decorator_spec.rb |