mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-25 07:05:20 +00:00
Isolate each role section in a context
This commit is contained in:
parent
7508fc1c92
commit
2d52303cdf
|
@ -12,29 +12,42 @@ RSpec.describe Admin::BaseController do
|
|||
|
||||
before { routes.draw { get 'success' => 'admin/base#success' } }
|
||||
|
||||
it 'requires administrator or moderator' do
|
||||
sign_in(Fabricate(:user))
|
||||
context 'when accessed by regular user' do
|
||||
before { sign_in(Fabricate(:user)) }
|
||||
|
||||
it 'returns forbidden' do
|
||||
get :success
|
||||
|
||||
expect(response).to have_http_status(403)
|
||||
expect(response)
|
||||
.to have_http_status(403)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns private cache control headers' do
|
||||
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
|
||||
context 'when accessed by moderator' do
|
||||
before { sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator'))) }
|
||||
|
||||
it 'returns http success, private cache control, and uses admin layout' do
|
||||
get :success
|
||||
|
||||
expect(response.headers['Cache-Control']).to include('private, no-store')
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response.headers['Cache-Control'])
|
||||
.to include('private, no-store')
|
||||
expect(response)
|
||||
.to render_template layout: 'admin'
|
||||
end
|
||||
end
|
||||
|
||||
it 'renders admin layout as a moderator' do
|
||||
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
|
||||
get :success
|
||||
expect(response).to render_template layout: 'admin'
|
||||
end
|
||||
context 'when accessed by admin' do
|
||||
before { sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin'))) }
|
||||
|
||||
it 'renders admin layout as an admin' do
|
||||
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin')))
|
||||
it 'returns http success and uses admin layout' do
|
||||
get :success
|
||||
expect(response).to render_template layout: 'admin'
|
||||
|
||||
expect(response)
|
||||
.to have_http_status(200)
|
||||
expect(response)
|
||||
.to render_template layout: 'admin'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue