From 6635a6f71da12218433ad43baead98d1763f31a9 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 21 Jun 2024 12:15:34 -0400 Subject: [PATCH] Fix `RSpec/LetSetup` cop in api/v1/timelines/tag spec --- spec/requests/api/v1/timelines/tag_spec.rb | 23 ++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/spec/requests/api/v1/timelines/tag_spec.rb b/spec/requests/api/v1/timelines/tag_spec.rb index 5e1415bb1ac..cfbfa0291c5 100644 --- a/spec/requests/api/v1/timelines/tag_spec.rb +++ b/spec/requests/api/v1/timelines/tag_spec.rb @@ -8,22 +8,25 @@ RSpec.describe 'Tag' do let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: scopes) } let(:headers) { { 'Authorization' => "Bearer #{token.token}" } } - shared_examples 'a successful request to the tag timeline' do - it 'returns the expected statuses', :aggregate_failures do - subject - - expect(response).to have_http_status(200) - expect(body_as_json.pluck(:id)).to match_array(expected_statuses.map { |status| status.id.to_s }) - end - end - describe 'GET /api/v1/timelines/tag/:hashtag' do subject do get "/api/v1/timelines/tag/#{hashtag}", headers: headers, params: params end + shared_examples 'a successful request to the tag timeline' do + it 'returns the expected statuses', :aggregate_failures do + subject + + expect(response) + .to have_http_status(200) + expect(body_as_json.pluck(:id)) + .to match_array(expected_statuses.map { |status| status.id.to_s }) + .and not_include(private_status.id) + end + end + let(:account) { Fabricate(:account) } - let!(:private_status) { PostStatusService.new.call(account, visibility: :private, text: '#life could be a dream') } # rubocop:disable RSpec/LetSetup + let!(:private_status) { PostStatusService.new.call(account, visibility: :private, text: '#life could be a dream') } let!(:life_status) { PostStatusService.new.call(account, text: 'tell me what is my #life without your #love') } let!(:war_status) { PostStatusService.new.call(user.account, text: '#war, war never changes') } let!(:love_status) { PostStatusService.new.call(account, text: 'what is #love?') }