From 72ccdfdf9bbea6269bc1a28199373abd5e8ce302 Mon Sep 17 00:00:00 2001 From: HombreLaser Date: Tue, 4 Apr 2023 19:53:27 -0600 Subject: AƱade specs de ReviewsController MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reviews/has_user_already_posted_review_query.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 app/queries/reviews/has_user_already_posted_review_query.rb (limited to 'app/queries') diff --git a/app/queries/reviews/has_user_already_posted_review_query.rb b/app/queries/reviews/has_user_already_posted_review_query.rb new file mode 100644 index 0000000..182f12e --- /dev/null +++ b/app/queries/reviews/has_user_already_posted_review_query.rb @@ -0,0 +1,14 @@ +# frozen_string_literal + +module Reviews + # HasUserAlreadyPostedReviewQuery + class HasUserAlreadyPostedReviewQuery + def initialize(product) + @product = product + end + + def review_posted?(user_account_id) + ProductReview.find_by(user_account_id:, product_id: @product.id).present? + end + end +end -- cgit v1.2.3