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 --- app/controllers/api/reviews_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'app/controllers/api/reviews_controller.rb') diff --git a/app/controllers/api/reviews_controller.rb b/app/controllers/api/reviews_controller.rb index 1f48362..52e7ec3 100644 --- a/app/controllers/api/reviews_controller.rb +++ b/app/controllers/api/reviews_controller.rb @@ -10,6 +10,12 @@ module Api render status: :not_found and return if @product.nil? + if params[:by].present? + render json: { posted: Reviews::HasUserAlreadyPostedReviewQuery.new(@product).review_posted?(params[:by]) }, + status: :ok + return + end + @reviews = @product.product_reviews.joins(:user_account).select('product_reviews.*', 'user_accounts.first_name as author_name') render json: serialized_collection.serializable_hash, status: :ok @@ -41,7 +47,7 @@ module Api end def serialized_collection - @serialized_collection ||= ProductReviewSerializer.new(@reviews) + @serialized_collection ||= ProductReviewSerializer.new(@reviews.page(params[:page])) end def serialized_object -- cgit v1.2.3