diff options
Diffstat (limited to 'spec/controllers/admin/users_controller_spec.rb')
-rw-r--r-- | spec/controllers/admin/users_controller_spec.rb | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index 5312a0db7f5..d0d1fa6a6bc 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -107,49 +107,40 @@ RSpec.describe Admin::UsersController do subject { put :approve, params: { id: user.username } } - context 'when feature is disabled' do - before do - stub_feature_flags(admin_approval_for_new_user_signups: false) - end - - it 'responds with access denied' do + context 'when successful' do + it 'activates the user' do subject - expect(response).to have_gitlab_http_status(:not_found) + user.reload + + expect(user).to be_active + expect(flash[:notice]).to eq('Successfully approved') end - end - context 'when feature is enabled' do - before do - stub_feature_flags(admin_approval_for_new_user_signups: true) + it 'emails the user on approval' do + expect(DeviseMailer).to receive(:user_admin_approval).with(user).and_call_original + expect { subject }.to have_enqueued_mail(DeviseMailer, :user_admin_approval) end + end - context 'when successful' do - it 'activates the user' do - subject + context 'when unsuccessful' do + let(:user) { create(:user, :blocked) } - user.reload + it 'displays the error' do + subject - expect(user).to be_active - expect(flash[:notice]).to eq('Successfully approved') - end + expect(flash[:alert]).to eq('The user you are trying to approve is not pending an approval') end - context 'when unsuccessful' do - let(:user) { create(:user, :blocked) } - - it 'displays the error' do - subject - - expect(flash[:alert]).to eq('The user you are trying to approve is not pending an approval') - end + it 'does not activate the user' do + subject - it 'does not activate the user' do - subject + user.reload + expect(user).not_to be_active + end - user.reload - expect(user).not_to be_active - end + it 'does not email the pending user' do + expect { subject }.not_to have_enqueued_mail(DeviseMailer, :user_admin_approval) end end end |