summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-04-04 19:53:27 -0600
committerHombreLaser <sebastian-440@live.com>2023-04-04 19:53:27 -0600
commit72ccdfdf9bbea6269bc1a28199373abd5e8ce302 (patch)
treedf69179a101d71e9fe8ae22753c3bb7a95f8e5e7 /app/controllers
parentdb9b4b712271a67e60e6c0bf58c9ce510f177682 (diff)
Añade specs de ReviewsController
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/api/reviews_controller.rb8
1 files changed, 7 insertions, 1 deletions
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