diff --git a/app/mailers/emails/admin_notification.rb b/app/mailers/emails/admin_notification.rb index 35814eb5647b53dee9ca658f8c8a51cf47d32135..44755e486acc11472dcee5b0cf9f4e3921dfb34f 100644 --- a/app/mailers/emails/admin_notification.rb +++ b/app/mailers/emails/admin_notification.rb @@ -7,13 +7,13 @@ def send_admin_notification(user_id, subj, body) email = user.notification_email_or_default @unsubscribe_url = unsubscribe_url(email: Base64.urlsafe_encode64(email)) @body = body - mail_with_locale to: email, subject: subject(subj) + email_with_layout to: email, subject: subject(subj) end def send_unsubscribed_notification(user_id) user = User.find(user_id) email = user.notification_email_or_default - mail_with_locale to: email, subject: subject("Unsubscribed from GitLab administrator notifications") + email_with_layout to: email, subject: subject("Unsubscribed from GitLab administrator notifications") end end end diff --git a/app/mailers/emails/pages_domains.rb b/app/mailers/emails/pages_domains.rb index a0975952feec93f73764a59475107bf1c830a7a9..7d0281b44b9a5254ae3205f1daae9d2a07008801 100644 --- a/app/mailers/emails/pages_domains.rb +++ b/app/mailers/emails/pages_domains.rb @@ -6,7 +6,7 @@ def pages_domain_enabled_email(domain, recipient) @domain = domain @project = domain.project - mail_with_locale( + email_with_layout( to: recipient.notification_email_for(@project.group), subject: subject("GitLab Pages domain '#{domain.domain}' has been enabled") ) @@ -16,7 +16,7 @@ def pages_domain_disabled_email(domain, recipient) @domain = domain @project = domain.project - mail_with_locale( + email_with_layout( to: recipient.notification_email_for(@project.group), subject: subject("GitLab Pages domain '#{domain.domain}' has been disabled") ) @@ -26,7 +26,7 @@ def pages_domain_verification_succeeded_email(domain, recipient) @domain = domain @project = domain.project - mail_with_locale( + email_with_layout( to: recipient.notification_email_for(@project.group), subject: subject("Verification succeeded for GitLab Pages domain '#{domain.domain}'") ) @@ -36,7 +36,7 @@ def pages_domain_verification_failed_email(domain, recipient) @domain = domain @project = domain.project - mail_with_locale( + email_with_layout( to: recipient.notification_email_for(@project.group), subject: subject("ACTION REQUIRED: Verification failed for GitLab Pages domain '#{domain.domain}'") ) @@ -50,7 +50,7 @@ def pages_domain_auto_ssl_failed_email(domain, recipient) "ACTION REQUIRED: Something went wrong while obtaining the Let's Encrypt certificate for " \ "GitLab Pages domain '%{domain}'" ) % { domain: domain.domain } - mail_with_locale( + email_with_layout( to: recipient.notification_email_for(@project.group), subject: subject(subject_text) ) diff --git a/app/mailers/emails/profile.rb b/app/mailers/emails/profile.rb index 18ae1341bea6fccdaafeac983d0292ae7d90a930..8352a382f8c6e903015b89ae3f3ea3c4b39f7c38 100644 --- a/app/mailers/emails/profile.rb +++ b/app/mailers/emails/profile.rb @@ -75,7 +75,7 @@ def bot_resource_access_token_about_to_expire_email(recipient, resource, token_n @reason_text = _('You are receiving this email because you are either an Owner or Maintainer of the project.') end - mail_with_locale( + email_with_layout( to: recipient.notification_email_or_default, subject: subject( safe_format( diff --git a/app/mailers/previews/notify_preview.rb b/app/mailers/previews/notify_preview.rb index 6a3f0d95fa570a2a29dddeff9cc6ef2bfd7af123..e108d13b6336273c61c7bf15f1440b32a97d88ce 100644 --- a/app/mailers/previews/notify_preview.rb +++ b/app/mailers/previews/notify_preview.rb @@ -201,17 +201,34 @@ def member_about_to_expire_email def pages_domain_enabled_email cleanup do - pages_domain = PagesDomain.new( - domain: 'my.example.com', - project: project, - verified_at: Time.now, - enabled_until: 1.week.from_now - ) - Notify.pages_domain_enabled_email(pages_domain, user).message end end + def pages_domain_disabled_email + cleanup do + Notify.pages_domain_disabled_email(pages_domain, user).message + end + end + + def pages_domain_verification_succeeded_email + cleanup do + Notify.pages_domain_verification_succeeded_email(pages_domain, user).message + end + end + + def pages_domain_verification_failed_email + cleanup do + Notify.pages_domain_verification_failed_email(pages_domain, user).message + end + end + + def pages_domain_auto_ssl_failed_email + cleanup do + Notify.pages_domain_auto_ssl_failed_email(pages_domain, user).message + end + end + def pipeline_success_email Notify.pipeline_success_email(pipeline, pipeline.user.try(:email)) end @@ -544,6 +561,15 @@ def cleanup email end + + def pages_domain + @pages_domain ||= PagesDomain.new( + domain: 'my.example.com', + project: project, + verified_at: Time.now, + enabled_until: 1.week.from_now + ) + end end NotifyPreview.prepend_mod_with('Preview::NotifyPreview') diff --git a/spec/mailers/emails/pages_domains_spec.rb b/spec/mailers/emails/pages_domains_spec.rb index 480e89decf1b2eb55f357eadf1f300c464c2b2ff..08362319626e39327f0627337c2ae70da7124482 100644 --- a/spec/mailers/emails/pages_domains_spec.rb +++ b/spec/mailers/emails/pages_domains_spec.rb @@ -17,6 +17,8 @@ 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_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the expected content' do aggregate_failures do @@ -65,7 +67,6 @@ subject { Notify.pages_domain_enabled_email(domain, user) } it_behaves_like 'a pages domain verification email' - it { is_expected.to have_body_text 'has been enabled' } end diff --git a/spec/mailers/emails/profile_spec.rb b/spec/mailers/emails/profile_spec.rb index 87de8b59ad6e19f40cab99e7c71d759bba6be59d..02cf1c20dca30f5f26dc92697a7b8881deae334a 100644 --- a/spec/mailers/emails/profile_spec.rb +++ b/spec/mailers/emails/profile_spec.rb @@ -217,6 +217,8 @@ it_behaves_like 'it should not have Gmail Actions links' it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'resource about to expire email' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'includes the email reason' do is_expected.to have_body_text _('You are receiving this email because you are an Owner of the Group.') @@ -246,6 +248,8 @@ it_behaves_like 'it should not have Gmail Actions links' it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'resource about to expire email' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'includes the email reason' do is_expected.to have_body_text _('You are receiving this email because you are either an Owner or Maintainer of the project.') diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 2afefdc9d04a97417da1e5d822da17e9f3a9b61a..9dcb0cdf103e2ffedb820dcfda32b357c362d147 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -1887,11 +1887,10 @@ def invite_to_group(group, inviter:, user: nil) subject { @email = described_class.send_admin_notification(user.id, 'Admin announcement', 'Text') } - it 'is sent as the author' do - sender = subject.header[:from].addrs[0] - expect(sender.display_name).to eq("GitLab") - expect(sender.address).to eq(gitlab_sender) - end + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent to recipient' do is_expected.to deliver_to user.email @@ -1908,6 +1907,21 @@ def invite_to_group(group, inviter:, user: nil) end end + describe 'admin unsubscribe notification' do + let(:user) { create(:user) } + + subject { @email = described_class.send_unsubscribed_notification(user.id) } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'it should not have Gmail Actions links' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + + it 'is sent to recipient' do + is_expected.to deliver_to user.email + end + end + describe 'confirmation if email changed' do let(:example_site_path) { root_path } let(:user) { create(:user, email: 'old-email@mail.com') }