From 5d9513aaea75e4dd5773c94cc51710a7b361035f Mon Sep 17 00:00:00 2001 From: Akihiko Odaki Date: Fri, 26 May 2017 21:13:26 +0900 Subject: [PATCH] Spec Admin::BaseController (#3328) --- .../controllers/admin/base_controller_spec.rb | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 spec/controllers/admin/base_controller_spec.rb diff --git a/spec/controllers/admin/base_controller_spec.rb b/spec/controllers/admin/base_controller_spec.rb new file mode 100644 index 0000000000..2b60e7e924 --- /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