Reduce expectations for `RSpec/MultipleExpectations` cop in `controllers/statuses` spec (#27875)

This commit is contained in:
Matt Jankowski 2023-11-16 04:54:51 -05:00 committed by GitHub
parent 669a7157cb
commit c1f93def40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 134 additions and 87 deletions

View File

@ -57,11 +57,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'public'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('public'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -72,12 +75,15 @@ describe StatusesController do
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -157,11 +163,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -170,13 +179,16 @@ describe StatusesController do
let(:format) { 'json' }
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -194,11 +206,15 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -207,13 +223,16 @@ describe StatusesController do
let(:format) { 'json' }
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -254,11 +273,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -267,13 +289,16 @@ describe StatusesController do
let(:format) { 'json' }
it 'renders ActivityPub Note object successfully' do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -340,11 +365,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -355,12 +383,15 @@ describe StatusesController do
it_behaves_like 'cacheable response', expects_vary: 'Accept, Accept-Language, Cookie'
it 'renders ActivityPub Note object successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -378,11 +409,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -391,13 +425,17 @@ describe StatusesController do
let(:format) { 'json' }
it 'renders ActivityPub Note object successfully' do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -438,11 +476,14 @@ describe StatusesController do
let(:format) { 'html' }
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response).to render_template(:show)
expect(response)
.to have_http_status(200)
.and render_template(:show)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end
@ -451,13 +492,16 @@ describe StatusesController do
let(:format) { 'json' }
it 'renders ActivityPub Note object', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'private'
expect(response.headers['Content-Type']).to include 'application/activity+json'
json = body_as_json
expect(json[:content]).to include status.text
expect(response)
.to have_http_status(200)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('private'),
'Content-Type' => include('application/activity+json'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(body_as_json)
.to include(content: include(status.text))
end
end
end
@ -732,11 +776,14 @@ describe StatusesController do
end
it 'renders status successfully', :aggregate_failures do
expect(response).to have_http_status(200)
expect(response.headers['Link'].to_s).to include 'activity+json'
expect(response.headers['Vary']).to eq 'Accept, Accept-Language, Cookie'
expect(response.headers['Cache-Control']).to include 'public'
expect(response).to render_template(:embed)
expect(response)
.to have_http_status(200)
.and render_template(:embed)
expect(response.headers).to include(
'Vary' => 'Accept, Accept-Language, Cookie',
'Cache-Control' => include('public'),
'Link' => satisfy { |header| header.to_s.include?('activity+json') }
)
expect(response.body).to include status.text
end
end