summaryrefslogtreecommitdiff
path: root/app
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 /app
parent61110336bc5a924346f0654cb5bb812101c3bc7a (diff)
Añade specs de product_cart
Diffstat (limited to 'app')
-rw-r--r--app/models/product_cart.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/product_cart.rb b/app/models/product_cart.rb
index eb9cf9f..09e7a25 100644
--- a/app/models/product_cart.rb
+++ b/app/models/product_cart.rb
@@ -10,7 +10,7 @@ class ProductCart < ApplicationRecord
validate :sole_product_in_cart
def sole_product_in_cart
- return if cart.products.find_by(id: product_id).nil?
+ return if cart.nil? || cart.products.find_by(id: product_id).nil?
errors.add(:product_id, "cart already has product with id #{product_id}")
end