diff options
Diffstat (limited to 'spec/controllers/admin')
-rw-r--r-- | spec/controllers/admin/dashboard_controller_spec.rb | 12 | ||||
-rw-r--r-- | spec/controllers/admin/users_controller_spec.rb | 53 |
2 files changed, 32 insertions, 33 deletions
diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 283d82a3ab8..bfbd2ca946f 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -4,12 +4,20 @@ require 'spec_helper' RSpec.describe Admin::DashboardController do describe '#index' do + before do + sign_in(create(:admin)) + end + + it 'retrieves Redis versions' do + get :index + + expect(assigns[:redis_versions].length).to eq(1) + end + context 'with pending_delete projects' do render_views it 'does not retrieve projects that are pending deletion' do - sign_in(create(:admin)) - project = create(:project) pending_delete_project = create(:project, pending_delete: true) 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 |