diff --git a/spec/controllers/statuses_controller_spec.rb b/spec/controllers/statuses_controller_spec.rb index 8b715824b88..fe40ee6de17 100644 --- a/spec/controllers/statuses_controller_spec.rb +++ b/spec/controllers/statuses_controller_spec.rb @@ -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