2017-05-26 08:13:26 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'rails_helper'
|
|
|
|
|
|
|
|
describe Admin::BaseController, type: :controller do
|
|
|
|
controller do
|
|
|
|
def success
|
|
|
|
render 'admin/reports/show'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-04-03 07:07:32 -04:00
|
|
|
it 'requires administrator or moderator' do
|
2017-05-26 08:13:26 -04:00
|
|
|
routes.draw { get 'success' => 'admin/base#success' }
|
2018-04-03 07:07:32 -04:00
|
|
|
sign_in(Fabricate(:user, admin: false, moderator: false))
|
2017-05-26 08:13:26 -04:00
|
|
|
get :success
|
2018-04-03 07:07:32 -04:00
|
|
|
|
|
|
|
expect(response).to have_http_status(:forbidden)
|
2017-05-26 08:13:26 -04:00
|
|
|
end
|
|
|
|
|
2018-04-03 07:07:32 -04:00
|
|
|
it 'renders admin layout as a moderator' do
|
2017-05-26 08:13:26 -04:00
|
|
|
routes.draw { get 'success' => 'admin/base#success' }
|
2018-04-03 07:07:32 -04:00
|
|
|
sign_in(Fabricate(:user, moderator: true))
|
2017-05-26 08:13:26 -04:00
|
|
|
get :success
|
2018-04-03 07:07:32 -04:00
|
|
|
expect(response).to render_template layout: 'admin'
|
|
|
|
end
|
2017-05-26 08:13:26 -04:00
|
|
|
|
2018-04-03 07:07:32 -04:00
|
|
|
it 'renders admin layout as an admin' do
|
|
|
|
routes.draw { get 'success' => 'admin/base#success' }
|
|
|
|
sign_in(Fabricate(:user, admin: true))
|
|
|
|
get :success
|
|
|
|
expect(response).to render_template layout: 'admin'
|
2017-05-26 08:13:26 -04:00
|
|
|
end
|
|
|
|
end
|