base_controller_spec.rb 605 B

1234567891011121314151617181920212223242526
  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. describe Admin::BaseController, type: :controller do
  4. controller do
  5. def success
  6. render 'admin/reports/show'
  7. end
  8. end
  9. it 'renders admin layout' do
  10. routes.draw { get 'success' => 'admin/base#success' }
  11. sign_in(Fabricate(:user, admin: true))
  12. get :success
  13. expect(response).to render_template layout: 'admin'
  14. end
  15. it 'requires administrator' do
  16. routes.draw { get 'success' => 'admin/base#success' }
  17. sign_in(Fabricate(:user, admin: false))
  18. get :success
  19. expect(response).to redirect_to('/')
  20. end
  21. end