闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
891 B

  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