about summary refs log tree commit diff
path: root/spec/controllers/admin/base_controller_spec.rb
blob: 2b60e7e92409cfb224115b46adb48b3edff4cc5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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