Spec Admin::BaseController (#3328)

rebase/4.0.0rc2
Akihiko Odaki 2017-05-26 21:13:26 +09:00 committed by Eugen Rochko
parent 4b11675bdc
commit 019f3377bb
1 changed files with 26 additions and 0 deletions

View File

@ -0,0 +1,26 @@
# frozen_string_literal: true
require 'rails_helper'
describe Admin::BaseController, type: :controller do
controller do
def success
render 'admin/reports/show'
end
end
it 'renders admin layout' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, admin: true))
get :success
expect(response).to render_template layout: 'admin'
end
it 'requires administrator' do
routes.draw { get 'success' => 'admin/base#success' }
sign_in(Fabricate(:user, admin: false))
get :success
expect(response).to redirect_to('/')
end
end