Commit 5ef81a22 by Hoang Phuc Do

Update RSpec for Product model

parent bd5bb37b
......@@ -21,4 +21,18 @@ RSpec.describe Product, type: :model do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:category) }
end
context 'custom methods' do
let!(:user) { create(:user) }
let!(:other_user) { create(:user) }
let!(:product) { create(:product, quantity: 3, user: other_user) }
it 'has valid in_stock?' do
expect(product.in_stock?(2)).to be_truthy
end
it 'has valid belongs_to_user?' do
expect(product.belongs_to_user?(user)).not_to be_truthy
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment