1
0
Fork 0
mirror of https://github.com/mastodon/mastodon.git synced 2024-08-20 21:08:15 -07:00
mastodon/spec/controllers/admin/base_controller_spec.rb

43 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2017-05-26 05:13:26 -07:00
# frozen_string_literal: true
require 'rails_helper'
describe Admin::BaseController do
2017-05-26 05:13:26 -07:00
controller do
def success
authorize :dashboard, :index?
2017-05-26 05:13:26 -07:00
render 'admin/reports/show'
end
end
it 'requires administrator or moderator' do
2017-05-26 05:13:26 -07:00
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user))
2017-05-26 05:13:26 -07:00
get :success
expect(response).to have_http_status(403)
2017-05-26 05:13:26 -07:00
end
it 'returns private cache control headers' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
get :success
expect(response.headers['Cache-Control']).to include('private, no-store')
end
it 'renders admin layout as a moderator' do
2017-05-26 05:13:26 -07:00
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Moderator')))
2017-05-26 05:13:26 -07:00
get :success
expect(response).to render_template layout: 'admin'
end
2017-05-26 05:13:26 -07:00
it 'renders admin layout as an admin' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, role: UserRole.find_by(name: 'Admin')))
get :success
expect(response).to render_template layout: 'admin'
2017-05-26 05:13:26 -07:00
end
end