Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/users/approve_service_spec.rb')
-rw-r--r--spec/services/users/approve_service_spec.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/services/users/approve_service_spec.rb b/spec/services/users/approve_service_spec.rb
index 1b063a9ad1c..09379857c38 100644
--- a/spec/services/users/approve_service_spec.rb
+++ b/spec/services/users/approve_service_spec.rb
@@ -75,6 +75,24 @@ RSpec.describe Users::ApproveService, feature_category: :user_management do
expect { subject }.to have_enqueued_mail(DeviseMailer, :user_admin_approval)
end
+ context 'when the user was created via sign up' do
+ it 'does not send a password reset email' do
+ expect { subject }.not_to have_enqueued_mail(Notify, :new_user_email)
+ end
+ end
+
+ context 'when the user was created by an admin' do
+ let(:user) { create(:user, :blocked_pending_approval, created_by_id: current_user.id) }
+
+ it 'sends a password reset email' do
+ allow(user).to receive(:generate_reset_token).and_return(:reset_token)
+
+ expect(Notify).to receive(:new_user_email).with(user.id, :reset_token).and_call_original
+
+ expect { subject }.to have_enqueued_mail(Notify, :new_user_email)
+ end
+ end
+
context 'email confirmation status' do
context 'user is unconfirmed' do
let(:user) { create(:user, :blocked_pending_approval, :unconfirmed) }