-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
AO3-6493 Notify wrangling supervisors via email when a wrangler chang…
…es their username (#4802) * AO3-6493 Basic functionality * AO3-6493 Only notify for wranglers * AO3-6493 I18n emails * AO3-6493 Configurable email address * AO3-6493 Better email address config name * AO3-6493 Come to me doggy * AO3-6493 Reviewdog * AO3-6493 Use placeholder email address * AO3-6493 Rename TagWranglingAdminMailer to TagWranglingSupervisorMailer * AO3-6493 Use standard informal greeting
- Loading branch information
Showing
9 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class TagWranglingSupervisorMailer < ApplicationMailer | ||
default to: ArchiveConfig.TAG_WRANGLER_SUPERVISORS_ADDRESS | ||
|
||
# Send an email to tag wrangling supervisors when a tag wrangler changes their username | ||
def wrangler_username_change_notification(old_name, new_name) | ||
@old_username = old_name | ||
@new_username = new_name | ||
mail( | ||
subject: default_i18n_subject(app_name: ArchiveConfig.APP_SHORT_NAME) | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
app/views/tag_wrangling_supervisor_mailer/wrangler_username_change_notification.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<% content_for :message do %> | ||
<p><%= t("mailer.general.greeting.informal.addressed", name: style_bold(t("mailer.general.greeting.tag_wrangler_supervisors"))).html_safe %></p> | ||
|
||
<p><%= t(".name_changed.html", old_username: style_bold(@old_username), new_username: style_bold(@new_username)) %></p> | ||
|
||
<p> | ||
<%= t("mailer.general.closing.informal") %><br /> | ||
<%= t("mailer.general.signature.app_short_name") %> | ||
</p> | ||
<% end %> |
8 changes: 8 additions & 0 deletions
8
app/views/tag_wrangling_supervisor_mailer/wrangler_username_change_notification.text.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% content_for :message do %> | ||
<%= t("mailer.general.greeting.informal.addressed", name: t("mailer.general.greeting.tag_wrangler_supervisors")) %> | ||
<%= t(".name_changed.html", old_username: @old_username, new_username: @new_username) %> | ||
<%= t("mailer.general.closing.informal") %> | ||
<%= t("mailer.general.signature.app_short_name") %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ RETURN_ADDRESS: '[email protected]' | |
SPAM_ALERT_ADDRESS: '[email protected]' | ||
SPAM_THRESHOLD: 15 | ||
ADMIN_ADDRESS: '[email protected]' | ||
TAG_WRANGLER_SUPERVISORS_ADDRESS: '[email protected]' | ||
|
||
# Because the default email addresses are fake, | ||
# email delivery is turned off by default, even for production. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,3 +211,25 @@ Feature: | |
And I press "Change User Name" | ||
Then I should get confirmation that I changed my username | ||
And I should see "Hi, notforbidden" | ||
|
||
Scenario: Tag wrangling supervisors are emailed about tag wrangler username changes | ||
Given the user "before" exists and is activated | ||
And I am logged in as "before" with password "password" | ||
And all emails have been delivered | ||
And I visit the change username page for before | ||
And I fill in "New user name" with "after" | ||
And I fill in "Password" with "password" | ||
And I press "Change User Name" | ||
Then 0 email should be delivered to "[email protected]" | ||
When the user "wrangler_before" exists and has the role "tag_wrangler" | ||
And I am logged in as "wrangler_before" with password "password" | ||
And all emails have been delivered | ||
And I visit the change username page for wrangler_before | ||
And I fill in "New user name" with "wrangler_after" | ||
And I fill in "Password" with "password" | ||
And I press "Change User Name" | ||
Then 1 email should be delivered to "[email protected]" | ||
And the email should contain "The wrangler" | ||
And the email should contain "wrangler_before" | ||
And the email should contain "has changed their name" | ||
And the email should contain "wrangler_after" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require "spec_helper" | ||
|
||
describe TagWranglingSupervisorMailer do | ||
describe "#wrangler_username_change_notification" do | ||
let(:email) { TagWranglingSupervisorMailer.wrangler_username_change_notification(old_name, new_name) } | ||
let(:old_name) { "fast" } | ||
let(:new_name) { "express" } | ||
|
||
it_behaves_like "an email with a valid sender" | ||
it_behaves_like "a multipart email" | ||
it_behaves_like "a translated email" | ||
|
||
it "has the correct subject line" do | ||
subject = "[#{ArchiveConfig.APP_SHORT_NAME}] Wrangler name change" | ||
expect(email).to have_subject(subject) | ||
end | ||
|
||
it "delivers to the correct address" do | ||
expect(email).to deliver_to ArchiveConfig.TAG_WRANGLER_SUPERVISORS_ADDRESS | ||
end | ||
|
||
describe "HTML version" do | ||
it "has the correct content" do | ||
expect(email).to have_html_part_content("The wrangler <b") | ||
expect(email).to have_html_part_content(">fast</b> has changed their name to <b") | ||
expect(email).to have_html_part_content(">express</b>.") | ||
end | ||
end | ||
|
||
describe "text version" do | ||
it "has the correct content" do | ||
expect(email).to have_text_part_content("The wrangler fast has changed their name to express.") | ||
end | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
test/mailers/previews/tag_wrangling_supervisor_mailer_preview.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class TagWranglingSupervisorMailerPreview < ApplicationMailerPreview | ||
# Sent to tag wrangling supervisors when a tag wrangler changes their username | ||
def wrangler_username_change_notification | ||
TagWranglingSupervisorMailer.wrangler_username_change_notification("anakin", "vader") | ||
end | ||
end |