diff options
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/in_product_marketing_spec.rb | 24 | ||||
-rw-r--r-- | spec/mailers/emails/merge_requests_spec.rb | 32 | ||||
-rw-r--r-- | spec/mailers/emails/projects_spec.rb | 28 |
3 files changed, 84 insertions, 0 deletions
diff --git a/spec/mailers/emails/in_product_marketing_spec.rb b/spec/mailers/emails/in_product_marketing_spec.rb index e62719f4283..7f3896a3d51 100644 --- a/spec/mailers/emails/in_product_marketing_spec.rb +++ b/spec/mailers/emails/in_product_marketing_spec.rb @@ -103,4 +103,28 @@ RSpec.describe Emails::InProductMarketing do end end end + + describe '#build_ios_app_guide_email' do + subject { Notify.build_ios_app_guide_email(user.notification_email_or_default) } + + it 'sends to the right user' do + expect(subject).to deliver_to(user.notification_email_or_default) + end + + it 'has the correct subject and content' do + message = Gitlab::Email::Message::BuildIosAppGuide.new + cta_url = 'https://about.gitlab.com/blog/2019/03/06/ios-publishing-with-gitlab-and-fastlane/' + cta2_url = 'https://www.youtube.com/watch?v=325FyJt7ZG8' + + aggregate_failures do + is_expected.to have_subject(message.subject_line) + is_expected.to have_body_text(message.title) + is_expected.to have_body_text(message.body_line1) + is_expected.to have_body_text(CGI.unescapeHTML(message.cta_link)) + is_expected.to have_body_text(CGI.unescapeHTML(message.cta2_link)) + is_expected.to have_body_text(cta_url) + is_expected.to have_body_text(cta2_url) + end + end + end end diff --git a/spec/mailers/emails/merge_requests_spec.rb b/spec/mailers/emails/merge_requests_spec.rb index dea54f7315d..7682cf39450 100644 --- a/spec/mailers/emails/merge_requests_spec.rb +++ b/spec/mailers/emails/merge_requests_spec.rb @@ -65,7 +65,9 @@ RSpec.describe Emails::MergeRequests do is_expected.to have_body_text('due to conflict.') is_expected.to have_link(merge_request.to_reference, href: project_merge_request_url(merge_request.target_project, merge_request)) is_expected.to have_text_part_content(assignee.name) + is_expected.to have_html_part_content(assignee.name) is_expected.to have_text_part_content(reviewer.name) + is_expected.to have_html_part_content(reviewer.name) end end end @@ -182,6 +184,36 @@ RSpec.describe Emails::MergeRequests do end end + describe '#approved_merge_request_email' do + subject { Notify.approved_merge_request_email(recipient.id, merge_request.id, current_user.id) } + + it 'has the correct body' do + aggregate_failures do + is_expected.to have_body_text('was approved by') + is_expected.to have_body_text(current_user.name) + is_expected.to have_text_part_content(assignee.name) + is_expected.to have_html_part_content(assignee.name) + is_expected.to have_text_part_content(reviewer.name) + is_expected.to have_html_part_content(reviewer.name) + end + end + end + + describe '#unapproved_merge_request_email' do + subject { Notify.unapproved_merge_request_email(recipient.id, merge_request.id, current_user.id) } + + it 'has the correct body' do + aggregate_failures do + is_expected.to have_body_text('was unapproved by') + is_expected.to have_body_text(current_user.name) + is_expected.to have_text_part_content(assignee.name) + is_expected.to have_html_part_content(assignee.name) + is_expected.to have_text_part_content(reviewer.name) + is_expected.to have_html_part_content(reviewer.name) + end + end + end + describe "#resolved_all_discussions_email" do subject { Notify.resolved_all_discussions_email(recipient.id, merge_request.id, current_user.id) } diff --git a/spec/mailers/emails/projects_spec.rb b/spec/mailers/emails/projects_spec.rb index b9c71e35bc6..ef3c21b32ce 100644 --- a/spec/mailers/emails/projects_spec.rb +++ b/spec/mailers/emails/projects_spec.rb @@ -180,4 +180,32 @@ RSpec.describe Emails::Projects do end end end + + describe '.inactive_project_deletion_warning_email' do + let(:recipient) { user } + let(:deletion_date) { "2022-01-10" } + + subject { Notify.inactive_project_deletion_warning_email(project, user, deletion_date) } + + it_behaves_like 'an email sent to a user' + 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 + project_link = "<a href=\"#{project.http_url_to_repo}\">#{project.name}</a>" + + is_expected.to have_subject("#{project.name} | Action required: Project #{project.name} is scheduled to be " \ + "deleted on 2022-01-10 due to inactivity") + is_expected.to have_body_text(project.http_url_to_repo) + is_expected.to have_body_text("Due to inactivity, the #{project_link} project is scheduled to be deleted " \ + "on <b>2022-01-10</b>") + is_expected.to have_body_text("To ensure #{project_link} is unscheduled for deletion, check that activity has " \ + "been logged by GitLab") + is_expected.to have_body_text("This email supersedes any previous emails about scheduled deletion you may " \ + "have received for #{project_link}.") + end + end end |