Extract shared example for cacheable response in specs (#25388)
This commit is contained in:
parent
708299bb0d
commit
893b2f33fd
6 changed files with 27 additions and 91 deletions
|
@ -5,25 +5,6 @@ require 'rails_helper'
|
|||
describe StatusesController do
|
||||
render_views
|
||||
|
||||
shared_examples 'cacheable response' do
|
||||
it 'does not set cookies' do
|
||||
expect(response.cookies).to be_empty
|
||||
expect(response.headers['Set-Cookies']).to be_nil
|
||||
end
|
||||
|
||||
it 'does not set sessions' do
|
||||
expect(session).to be_empty
|
||||
end
|
||||
|
||||
it 'returns Vary header' do
|
||||
expect(response.headers['Vary']).to include 'Accept, Accept-Language, Cookie'
|
||||
end
|
||||
|
||||
it 'returns public Cache-Control header' do
|
||||
expect(response.headers['Cache-Control']).to include 'public'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #show' do
|
||||
let(:account) { Fabricate(:account) }
|
||||
let(:status) { Fabricate(:status, account: account) }
|
||||
|
@ -88,7 +69,7 @@ describe StatusesController do
|
|||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
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)
|
||||
|
@ -371,7 +352,7 @@ describe StatusesController do
|
|||
context 'with JSON' do
|
||||
let(:format) { 'json' }
|
||||
|
||||
it_behaves_like 'cacheable response'
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue