roles_controller_spec.rb 832 B

123456789101112131415161718192021222324252627282930313233
  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