diff options
author | Ruben Davila <rdavila84@gmail.com> | 2016-11-28 17:00:03 -0500 |
---|---|---|
committer | Ruben Davila <rdavila84@gmail.com> | 2016-11-28 17:00:03 -0500 |
commit | b62e2bedbfa49aacfc4847049aa589f045af15ce (patch) | |
tree | 6bf1896177f66219f019beda752261fa7b99cea1 /spec/mailers | |
parent | 5c6d3a99efa1d29291f0b58655d9fc7febb970f8 (diff) | |
download | gitlab-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.rb | 34 |
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 |