summaryrefslogtreecommitdiff
path: root/spec/mailers
diff options
context:
space:
mode:
authorSean McGivern <sean@mcgivern.me.uk>2016-11-29 12:05:23 +0000
committerSean McGivern <sean@mcgivern.me.uk>2016-11-29 12:05:23 +0000
commitd8eee8ed73de13a5af42a5cf6de8ec1194e45483 (patch)
tree4861b64cb35b8bdaa53f3b07427c455e748e1441 /spec/mailers
parent35212deb062dda60220a9a0929c26196c1c598b5 (diff)
parentb62e2bedbfa49aacfc4847049aa589f045af15ce (diff)
downloadgitlab-ce-d8eee8ed73de13a5af42a5cf6de8ec1194e45483.tar.gz
Merge branch '24880-configurable-plaintext-emails' into 'master'
Add setting to enable/disable HTML emails Closes #24880 See merge request !7749
Diffstat (limited to 'spec/mailers')
-rw-r--r--spec/mailers/notify_spec.rb34
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/mailers/notify_spec.rb b/spec/mailers/notify_spec.rb
index 39ba48f61cb..b692142713f 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -1172,4 +1172,38 @@ describe Notify do
is_expected.to have_body_text /#{diff_path}/
end
end
+
+ describe 'HTML emails setting' do
+ let(:project) { create(:project) }
+ let(:user) { create(:user) }
+ let(:multipart_mail) { Notify.project_was_moved_email(project.id, user.id, "gitlab/gitlab") }
+
+ context 'when disabled' do
+ it 'only sends the text template' do
+ stub_application_setting(html_emails_enabled: false)
+
+ EmailTemplateInterceptor.delivering_email(multipart_mail)
+
+ expect(multipart_mail).to have_part_with('text/plain')
+ expect(multipart_mail).not_to have_part_with('text/html')
+ end
+ end
+
+ context 'when enabled' do
+ it 'sends a multipart message' do
+ stub_application_setting(html_emails_enabled: true)
+
+ EmailTemplateInterceptor.delivering_email(multipart_mail)
+
+ expect(multipart_mail).to have_part_with('text/plain')
+ expect(multipart_mail).to have_part_with('text/html')
+ end
+ end
+
+ matcher :have_part_with do |expected|
+ match do |actual|
+ actual.body.parts.any? { |part| part.content_type.try(:match, %r(#{expected})) }
+ end
+ end
+ end
end