闭社主体 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
832 B

  1. require 'rails_helper'
  2. describe Admin::RolesController do
  3. render_views
  4. let(:admin) { Fabricate(:user, admin: true) }
  5. before do
  6. sign_in admin, scope: :user
  7. end
  8. describe 'POST #promote' do
  9. subject { post :promote, params: { account_id: user.account_id } }
  10. let(:user) { Fabricate(:user, moderator: false, admin: false) }
  11. it 'promotes user' do
  12. expect(subject).to redirect_to admin_account_path(user.account_id)
  13. expect(user.reload).to be_moderator
  14. end
  15. end
  16. describe 'POST #demote' do
  17. subject { post :demote, params: { account_id: user.account_id } }
  18. let(:user) { Fabricate(:user, moderator: true, admin: false) }
  19. it 'demotes user' do
  20. expect(subject).to redirect_to admin_account_path(user.account_id)
  21. expect(user.reload).not_to be_moderator
  22. end
  23. end
  24. end