diff options
author | Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-05-26 21:13:26 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-26 14:13:26 +0200 |
commit | 019f3377bbf845fcb97b55ab14c903c17e79a803 (patch) | |
tree | 4fc15ea38d1b7c7db9238a46d833cf51308d179a /spec/controllers | |
parent | 4b11675bdc0e99e3e03fde056a1e50e847cec81b (diff) |
Spec Admin::BaseController (#3328)
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/admin/base_controller_spec.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb new file mode 100644 index 000000000..2b60e7e92 --- /dev/null +++ b/spec/controllers/admin/base_controller_spec.rb @@ -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 |