summaryrefslogtreecommitdiff
path: root/spec/models/product_cart_spec.rb
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-06 15:29:08 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-06 15:29:08 -0600
commit4611fdd6da7f9a1cc04144104e5ca26398f1b502 (patch)
tree0e04bb1a480d3484cadb9cb3e9119da27ba2c38d /spec/models/product_cart_spec.rb
parent61110336bc5a924346f0654cb5bb812101c3bc7a (diff)
Añade specs de product_cart
Diffstat (limited to 'spec/models/product_cart_spec.rb')
-rw-r--r--spec/models/product_cart_spec.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/models/product_cart_spec.rb b/spec/models/product_cart_spec.rb
index 00a8f6c..2c4d9d1 100644
--- a/spec/models/product_cart_spec.rb
+++ b/spec/models/product_cart_spec.rb
@@ -12,4 +12,12 @@ RSpec.describe ProductCart, type: :model do
it 'should belong to cart' do
expect(product_cart).to respond_to(:cart)
end
+
+ describe '#sole_product_in_cart' do
+ it 'validates for duplicate products in the cart' do
+ another_product_cart = build(:product_cart, cart: product_cart.cart, product: product_cart.product)
+ expect(another_product_cart.save).to be_falsey
+ expect(another_product_cart.errors[:product_id]).to be_present
+ end
+ end
end