summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-04 17:55:20 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-04 17:55:20 -0600
commitdb9b4b712271a67e60e6c0bf58c9ce510f177682 (patch)
tree791da60f29a1ac3b73efff46493d96c0116318e0 /spec/models
parent3afd35371caa0677fd2f66491bd337d1673013dc (diff)
Mejora presentaciĆ³n de mensajes de error
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/product_review_spec.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/spec/models/product_review_spec.rb b/spec/models/product_review_spec.rb
index f4e4999..c8f7b69 100644
--- a/spec/models/product_review_spec.rb
+++ b/spec/models/product_review_spec.rb
@@ -3,6 +3,9 @@ require 'rails_helper'
RSpec.describe ProductReview, type: :model do
let(:review) { build(:product_review) }
+ it { should belong_to(:user_account) }
+ it { should belong_to(:product) }
+
it { should validate_presence_of(:review) }
it { should validate_presence_of(:rating) }
@@ -14,4 +17,13 @@ RSpec.describe ProductReview, type: :model do
expect(review.save).to be_falsey
end
end
+
+ describe '#sole_user_review' do
+ it "doesn't allow a user to post more than one review for any given product" do
+ review.save
+ other_review = build(:product_review, user_account: review.user_account, product: review.product)
+ expect(other_review.save).to be_falsey
+ expect(other_review.errors[:review]).to_not be_nil
+ end
+ end
end