logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

base_controller_spec.rb (891B)


  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 'requires administrator or moderator' do
  10. routes.draw { get 'success' => 'admin/base#success' }
  11. sign_in(Fabricate(:user, admin: false, moderator: false))
  12. get :success
  13. expect(response).to have_http_status(:forbidden)
  14. end
  15. it 'renders admin layout as a moderator' do
  16. routes.draw { get 'success' => 'admin/base#success' }
  17. sign_in(Fabricate(:user, moderator: true))
  18. get :success
  19. expect(response).to render_template layout: 'admin'
  20. end
  21. it 'renders admin layout as an admin' do
  22. routes.draw { get 'success' => 'admin/base#success' }
  23. sign_in(Fabricate(:user, admin: true))
  24. get :success
  25. expect(response).to render_template layout: 'admin'
  26. end
  27. end