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 --- spec/requests/reviews_controller/index_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 spec/requests/reviews_controller/index_spec.rb (limited to 'spec/requests/reviews_controller/index_spec.rb') diff --git a/spec/requests/reviews_controller/index_spec.rb b/spec/requests/reviews_controller/index_spec.rb new file mode 100644 index 0000000..1a2863d --- /dev/null +++ b/spec/requests/reviews_controller/index_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +RSpec.describe 'GET /api/products/:product_id/reviews', type: :request do + let!(:product) { create(:product, public_id: SecureRandom.hex(12)) } + + before(:each) do + create_list(:product_review, 26, product:) + end + + it_behaves_like 'a GET index request' do + let(:headers) { {} } + let(:route) { "/api/products/#{product.public_id}/reviews" } + let(:pagination_size) { 15 } + end + + describe '?by=:user_account_id' do + it 'tells if a product has a review made by the user with the id' do + user = create(:user_account) + create(:product_review, user_account: user, product:) + get "/api/products/#{product.public_id}/reviews?by=#{user.id}" + expect(response).to have_http_status(200) + expect(response.body).to include('true') + end + end +end -- cgit v1.2.3