diff options
author | Alexandru Croitor <acroitor@gitlab.com> | 2019-02-20 17:18:15 +0200 |
---|---|---|
committer | Alexandru Croitor <acroitor@gitlab.com> | 2019-02-27 22:07:50 +0200 |
commit | 77985826d94454514c40b8da926e13b3b3791841 (patch) | |
tree | 00da4c2f5b72001e38b56e9d994cabc278ec0d7c /spec/mailers/notify_spec.rb | |
parent | 177f9ca88b4d080e91b6c4ce2bba04d2fba95c07 (diff) | |
download | gitlab-ce-77985826d94454514c40b8da926e13b3b3791841.tar.gz |
Show header and footer system messages in email
* Add email_header_and_footer_enabled flag to appearances table
* Set email_header_and_footer_enabled default value to false
* Add checkbox to appearance to toggle show header and footer in emails
* Add email_header_and_footer_enabled to allowed params in controller
* Add header and footer messages to the html and text email layouts
* Remove the color styling for emails header and footer
* Add empty_mailer layout for emails without layout,
to have the header and footer applied
Diffstat (limited to 'spec/mailers/notify_spec.rb')
-rw-r--r-- | spec/mailers/notify_spec.rb | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb index 4f578c48d5b..15b04c9d066 100644 --- a/spec/mailers/notify_spec.rb +++ b/spec/mailers/notify_spec.rb @@ -53,6 +53,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject and body' do aggregate_failures do @@ -72,6 +74,9 @@ describe Notify do context 'when sent with a reason' do subject { described_class.new_issue_email(issue.assignees.first.id, issue.id, NotificationReason::ASSIGNED) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'includes the reason in a header' do is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED) end @@ -99,6 +104,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -118,6 +125,9 @@ describe Notify do context 'when sent with a reason' do subject { described_class.reassigned_issue_email(recipient.id, issue.id, [previous_assignee.id], current_user.id, NotificationReason::ASSIGNED) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'includes the reason in a header' do is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED) end @@ -134,6 +144,8 @@ describe Notify do it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with a labels subscriptions link in its footer' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -173,6 +185,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -199,6 +213,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'contains description about action taken' do is_expected.to have_body_text 'Issue was moved to another project' @@ -226,6 +242,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject and body' do aggregate_failures do @@ -243,6 +261,9 @@ describe Notify do context 'when sent with a reason' do subject { described_class.new_merge_request_email(merge_request.assignee_id, merge_request.id, NotificationReason::ASSIGNED) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'includes the reason in a header' do is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED) end @@ -270,6 +291,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like "an unsubscribeable thread" + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -289,6 +312,9 @@ describe Notify do context 'when sent with a reason' do subject { described_class.reassigned_merge_request_email(recipient.id, merge_request.id, previous_assignee.id, current_user.id, NotificationReason::ASSIGNED) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'includes the reason in a header' do is_expected.to have_header('X-GitLab-NotificationReason', NotificationReason::ASSIGNED) end @@ -313,6 +339,8 @@ describe Notify do it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like "an unsubscribeable thread" + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'contains the description' do is_expected.to have_body_text(merge_request.description) @@ -329,6 +357,8 @@ describe Notify do it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with a labels subscriptions link in its footer' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -352,6 +382,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -379,6 +411,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the merge author' do sender = subject.header[:from].addrs[0] @@ -413,6 +447,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the merge request author' do sender = subject.header[:from].addrs[0] @@ -442,6 +478,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the push user' do sender = subject.header[:from].addrs[0] @@ -482,6 +520,9 @@ describe Notify do subject { described_class.note_issue_email(recipient.id, third_note.id) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'has In-Reply-To header pointing to previous note in discussion' do expect(subject.header['In-Reply-To'].message_ids).to eq(["note_#{second_note.id}@#{host}"]) end @@ -502,6 +543,9 @@ describe Notify do subject { described_class.note_issue_email(recipient.id, note.id) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it 'has In-Reply-To header pointing to the issue' do expect(subject.header['In-Reply-To'].message_ids).to eq(["issue_#{note.noteable.id}@#{host}"]) end @@ -518,6 +562,9 @@ describe Notify do subject { described_class.note_project_snippet_email(project_snippet_note.author_id, project_snippet_note.id) } + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + it_behaves_like 'an answer to an existing thread with reply-by-email enabled' do let(:model) { project_snippet } end @@ -535,6 +582,8 @@ describe Notify do 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 correct subject and body' do is_expected.to have_subject("#{project.name} | Project was moved") @@ -559,6 +608,8 @@ describe Notify do 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 'contains all the useful information' do to_emails = subject.header[:to].addrs.map(&:address) @@ -582,6 +633,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Access to the #{project.full_name} project was denied" @@ -599,6 +652,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Access to the #{project.full_name} project was granted" @@ -629,6 +684,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Invitation to join the #{project.full_name} project" @@ -653,6 +710,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject 'Invitation accepted' @@ -676,6 +735,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject 'Invitation declined' @@ -708,6 +769,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Commit link' 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 correct subject and body' do aggregate_failures do @@ -732,6 +795,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject and body' do aggregate_failures do @@ -756,6 +821,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject and body' do aggregate_failures do @@ -819,6 +886,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Commit link' 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 correct subject' do is_expected.to have_subject "Re: #{project.name} | #{commit.title} (#{commit.short_id})" @@ -845,6 +914,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject' do is_expected.to have_referable_subject(merge_request, reply: true) @@ -871,6 +942,8 @@ describe Notify do end it_behaves_like 'it should show Gmail Actions View Issue link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'has the correct subject' do is_expected.to have_referable_subject(issue, reply: true) @@ -948,6 +1021,8 @@ describe Notify do it_behaves_like 'an email for a note on a diff discussion', :diff_note_on_commit it_behaves_like 'it should show Gmail Actions View Commit link' 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' end describe 'on a merge request' do @@ -958,6 +1033,8 @@ describe Notify do it_behaves_like 'an email for a note on a diff discussion', :diff_note_on_merge_request it_behaves_like 'it should show Gmail Actions View Merge request link' it_behaves_like 'an unsubscribeable thread' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' end end end @@ -976,6 +1053,8 @@ describe Notify do 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 'contains all the useful information' do to_emails = subject.header[:to].addrs.map(&:address) @@ -998,6 +1077,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Access to the #{group.name} group was denied" @@ -1014,6 +1095,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Access to the #{group.name} group was granted" @@ -1044,6 +1127,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject "Invitation to join the #{group.name} group" @@ -1068,6 +1153,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject 'Invitation accepted' @@ -1091,6 +1178,8 @@ describe Notify do 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 'contains all the useful information' do is_expected.to have_subject 'Invitation declined' @@ -1140,6 +1229,8 @@ describe Notify do it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1165,6 +1256,8 @@ describe Notify do it_behaves_like "a user cannot unsubscribe through footer link" it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1189,6 +1282,8 @@ describe Notify do it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1210,6 +1305,8 @@ describe Notify do it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1237,6 +1334,8 @@ describe Notify do it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1328,6 +1427,8 @@ describe Notify do it_behaves_like 'a user cannot unsubscribe through footer link' it_behaves_like 'an email with X-GitLab headers containing project details' it_behaves_like 'an email that contains a header with author username' + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' it 'is sent as the author' do sender = subject.header[:from].addrs[0] @@ -1348,6 +1449,11 @@ describe Notify do describe 'HTML emails setting' do let(:multipart_mail) { described_class.project_was_moved_email(project.id, user.id, "gitlab/gitlab") } + subject { multipart_mail } + + it_behaves_like 'appearance header and footer enabled' + it_behaves_like 'appearance header and footer not enabled' + context 'when disabled' do it 'only sends the text template' do stub_application_setting(html_emails_enabled: false) @@ -1386,6 +1492,8 @@ describe Notify do subject { described_class.note_personal_snippet_email(personal_snippet_note.author_id, personal_snippet_note.id) } 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 correct subject and body' do is_expected.to have_referable_subject(personal_snippet, reply: true) |