Commit d6703c88 authored by sfang97's avatar sfang97

Remove uneeded test

Email user when request to join instance approved

When a user's request to access an instance is approved they should
receive an email letting them know.

Committing for save

Update email conditionals

Committing for save

Committing for save

Rebased with master

Get notify mailer working

Delete unused files

Remove extra space

Update email text

Change notify back to devise mailer

Verify that email is working

Use letter opener to verify that email is sent and formatted correctly,
fix spec and static analysis errors

Remove unused functions

Re add removed test

Run bin rake gettext regen

Add negative test case

Add changelog entry

Remove username helper

Didn't need username helper, just used string interp

No plain strings

Use different string interp

Remove extra newlines

Add translation strings

Add equals sign

Address MR review comments

Clarify tests, DRY tests, add tests

Clarify email spec

Clarify deliver email to user email

Add missing space

Add html safe link

Clean up spec

Correct html safe link

Regex match link

Move link to email view

Move link out of email helper and into email view, which makes writing
specs way easier

Use percent interpolation instead of hash

Re run gettext regenerate

Change html haml email link

Rerun gettext regenerate

Match variable name

Rebase with master for merge conflict

Merge conflict resolution

Change resource to user

Fix static analysis errors

Change user back to resource
parent 7472a375
......@@ -13,6 +13,10 @@ class DeviseMailer < Devise::Mailer
devise_mail(record, :password_change_by_admin, opts)
end
def user_admin_approval(record, opts = {})
devise_mail(record, :user_admin_approval, opts)
end
protected
def subject_for(key)
......
......@@ -24,6 +24,10 @@ class DeviseMailerPreview < ActionMailer::Preview
DeviseMailer.password_change(unsaved_user, {})
end
def user_admin_approval
DeviseMailer.user_admin_approval(unsaved_user, {})
end
private
def unsaved_user
......
......@@ -15,6 +15,7 @@ module Users
# Please see Devise's implementation of `resend_confirmation_instructions` for detail.
user.resend_confirmation_instructions
user.accept_pending_invitations! if user.active_for_authentication?
DeviseMailer.user_admin_approval(user).deliver_later
success
else
......
= email_default_heading(say_hi(@resource))
%p
= _('Your GitLab account request has been approved!')
%p
= _('Your username is %{username}.') % { username: @resource.username }
%p
= _('Your sign-in page is %{url}.').html_safe % { url: link_to(Gitlab.config.gitlab.url, Gitlab.config.gitlab.url) }
<%= say_hi(@resource) %>
<%= _('Your GitLab account request has been approved!') %>
<%= _('Your username is %{username}.' % { username: @resource.username }) %>
<%= _('Your sign-in page is %{url}.' % { url: Gitlab.config.gitlab.url }) %>
---
title: Email user on admin account approval
merge_request: 45947
author:
type: added
......@@ -30,6 +30,8 @@ en:
subject: "Password Changed"
password_change_by_admin:
subject: "Password changed by administrator"
user_admin_approval:
subject: "Welcome to GitLab!"
omniauth_callbacks:
failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
success: "Successfully authenticated from %{kind} account."
......
......@@ -31173,6 +31173,9 @@ msgstr ""
msgid "Your GPG keys (%{count})"
msgstr ""
msgid "Your GitLab account request has been approved!"
msgstr ""
msgid "Your GitLab group"
msgstr ""
......@@ -31371,6 +31374,9 @@ msgstr ""
msgid "Your search didn't match any commits. Try a different query."
msgstr ""
msgid "Your sign-in page is %{url}."
msgstr ""
msgid "Your subscription expired!"
msgstr ""
......@@ -31380,6 +31386,9 @@ msgstr ""
msgid "Your subscription will expire in %{remaining_days}."
msgstr ""
msgid "Your username is %{username}."
msgstr ""
msgid "Zoom meeting added"
msgstr ""
......
......@@ -116,6 +116,11 @@ RSpec.describe Admin::UsersController do
expect(user).to be_active
expect(flash[:notice]).to eq('Successfully approved')
end
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 unsuccessful' do
......@@ -133,6 +138,10 @@ RSpec.describe Admin::UsersController do
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
......
......@@ -64,4 +64,34 @@ RSpec.describe DeviseMailer do
is_expected.to have_body_text /#{Gitlab.config.gitlab.url}/
end
end
describe '#user_admin_approval' do
subject { described_class.user_admin_approval(user) }
let_it_be(:user) { create(:user) }
it_behaves_like 'an email sent from GitLab'
it_behaves_like 'it should not have Gmail Actions links'
it_behaves_like 'a user cannot unsubscribe through footer link'
it 'is sent to the user' do
is_expected.to deliver_to user.email
end
it 'has the correct subject' do
is_expected.to have_subject 'Welcome to GitLab!'
end
it 'greets the user' do
is_expected.to have_body_text /Hi #{user.name}!/
end
it 'includes the correct content' do
is_expected.to have_body_text /Your GitLab account request has been approved!/
end
it 'includes a link to GitLab' do
is_expected.to have_link(Gitlab.config.gitlab.url)
end
end
end
......@@ -61,6 +61,11 @@ RSpec.describe Users::ApproveService do
expect(user.reload).to be_active
end
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
context 'email confirmation status' do
context 'user is unconfirmed' do
let(:user) { create(:user, :blocked_pending_approval, :unconfirmed) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment