Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new email content if user is authenticating to manage their subscriptions #1175

Merged
merged 1 commit into from Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 8 additions & 4 deletions app/builders/subscriber_auth_email_builder.rb
Expand Up @@ -25,16 +25,20 @@ def call
attr_reader :subscriber, :destination, :token

def subject
"Confirm your email address"
"Manage your GOV.UK email subscriptions"
end

def body
<<~BODY
# Click the link to confirm your email address
# Manage your GOV.UK email subscriptions

^ [Confirm your email address](#{link})
You can unsubscribe from emails or change your subscription at:

You need to do this to manage your GOV.UK email subscriptions. The link will stop working in 7 days.
#{link}

You’ll need to confirm your email address before you can make any changes.

The link will stop working in 7 days.

# Didn’t request this email?

Expand Down
8 changes: 7 additions & 1 deletion spec/builders/subscriber_auth_email_builder_spec.rb
Expand Up @@ -18,7 +18,13 @@
expect { call }.to change(Email, :count).by(1)
end

it "has a link to authenticate" do
it "has a subject line prompting the user to manage their subscriptions" do
subject = "Manage your GOV.UK email subscriptions"
email = call
expect(email.subject).to include(subject)
end

it "has body content has a link allowing users to authenticate and manage their subscriptions" do
link = "http://www.dev.gov.uk/destination?token=secret"
email = call
expect(email.body).to include(link)
Expand Down
4 changes: 2 additions & 2 deletions spec/features/create_an_auth_token_spec.rb
Expand Up @@ -39,13 +39,13 @@ def notify_email(subscriber, destination, redirect)
"body" => hash_including(
"email_address" => subscriber.address,
"personalisation" => hash_including(
"subject" => "Confirm your email address",
"subject" => "Manage your GOV.UK email subscriptions",
"body" => include("http://www.dev.gov.uk#{destination}?token="),
),
),
)
.with { |request|
token = request.body.match(/token=([^&)]+)/)[1]
token = request.body.match(/token=([^&\\]+)/)[1]
theseanything marked this conversation as resolved.
Show resolved Hide resolved

expect(decrypt_and_verify_token(token)).to eq(
"subscriber_id" => subscriber.id,
Expand Down
2 changes: 1 addition & 1 deletion spec/integration/subscribers_auth_token_spec.rb
Expand Up @@ -35,7 +35,7 @@
it "sends an email with the correct token" do
post path, params: params
expect(Email.count).to be 1
token = Email.last.body.match(/token=([^&)]+)/)[1]
token = Email.last.body.match(/token=([^&\n]+)/)[1]
theseanything marked this conversation as resolved.
Show resolved Hide resolved
expect(decrypt_and_verify_token(token)).to eq(
"subscriber_id" => subscriber.id,
"redirect" => redirect,
Expand Down