summaryrefslogtreecommitdiff
path: root/spec/mailers
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2016-11-28 17:00:03 -0500
committerRuben Davila <rdavila84@gmail.com>2016-11-28 17:00:03 -0500
commitb62e2bedbfa49aacfc4847049aa589f045af15ce (patch)
tree6bf1896177f66219f019beda752261fa7b99cea1 /spec/mailers
parent5c6d3a99efa1d29291f0b58655d9fc7febb970f8 (diff)
downloadgitlab-ce-b62e2bedbfa49aacfc4847049aa589f045af15ce.tar.gz
Add new configuration setting to enable/disable HTML emails.24880-configurable-plaintext-emails
This new global setting will allow admins to specify if HTML emails should be sent or not, this is basically useful when system administrators want to save some disk space by avoiding emails in HTML format and using only the Plain Text version.
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 932a5dc4862..0ad1cefbacc 100644
--- a/spec/mailers/notify_spec.rb
+++ b/spec/mailers/notify_spec.rb
@@ -1099,4 +1099,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