Fix PAT expiry warning links in plain-text emails
What does this MR do and why?
Plain-text notification emails render the settings URL inside a translated sentence, followed by a period, for example:
...personal access tokens settings https://gitlab.example.com/-/user_settings/personal_access_tokens.
Some email clients include that trailing period as part of the link, so clicking it leads to a 404. English and French are affected because in those languages the URL falls at the end of the sentence.
This MR changes each affected template to use one translatable string with a colon and the URL as a placeholder, matching the convention already used by the deploy token and resource access token expiry emails:
_('You can create a new one or check them in your personal access tokens settings: %{pat_link}') % { pat_link: @target_url }
Keeping the URL inside the msgid still lets translators control where the URL sits in the sentence. In Japanese and Chinese the URL is placed mid-sentence. The placeholder names pat_link and ssh_key_link are kept, since descriptive placeholder names are the norm in the catalog and tell translators what the URL points to.
Templates fixed (plain-text .text.erb only, under app/views/notify/):
access_token_about_to_expire_email.text.erbaccess_token_expired_email.text.erbaccess_token_revoked_email.text.erbaccess_token_created_email.text.erbaccess_token_rotated_email.text.erbssh_key_expiring_soon.text.erb(renamed tossh_key_expiring_soon_email.text.erb)ssh_key_expired_email.text.erb
locale/gitlab.pot is updated: the five old msgids with the trailing period were only used by these templates and are replaced by the new colon-plus-placeholder msgids. Net change is 5 msgids replaced, no entry added without a placeholder.
The plain-text template for the SSH key expiring soon email was named ssh_key_expiring_soon.text.erb while the mailer method is ssh_key_expiring_soon_email, so Rails never rendered it and that email went out as HTML only. The template is renamed to ssh_key_expiring_soon_email.text.erb so the plain-text part is sent again.
Three EE templates have the same issue but are owned by other feature areas and are not touched here. A follow-up issue is linked below.
References
Closes #591110
Follow-up for EE templates: #629139 (closed)
Screenshots or screen recordings
Rendered plain-text excerpts. The domain is an example.
Before:
You can create a new one or check them in your personal access tokens settings https://gitlab.example.com/-/user_settings/personal_access_tokens.After:
You can create a new one or check them in your personal access tokens settings: https://gitlab.example.com/-/user_settings/personal_access_tokensHow to set up and validate locally
Run the focused spec:
bundle exec rspec spec/mailers/emails/profile_spec.rbspec/mailers/emails/profile_spec.rb adds a shared example, "a plain-text email with an unpunctuated settings URL", used by all seven affected email specs. It asserts the plain-text body contains the settings URL and that no punctuation character (.,;:!?) directly follows it.
Local checks for the latest revision: Ruby syntax check of the spec, ERB compile check of all seven templates, and git diff --check. The RSpec suite runs in the MR pipeline.
MR acceptance checklist
- All seven plain-text templates render the settings URL without trailing punctuation
-
locale/gitlab.potupdated, no orphaned msgids - Regression coverage added for all seven emails
- Follow-up issue filed for the three EE templates
-
spec/mailers/emails/profile_spec.rbpasses in the MR pipeline