diff options
Diffstat (limited to 'spec/mailers')
-rw-r--r-- | spec/mailers/emails/service_desk_spec.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/spec/mailers/emails/service_desk_spec.rb b/spec/mailers/emails/service_desk_spec.rb index 25afa8b48ce..b81c0ec8617 100644 --- a/spec/mailers/emails/service_desk_spec.rb +++ b/spec/mailers/emails/service_desk_spec.rb @@ -3,7 +3,7 @@ require 'spec_helper' require 'email_spec' -RSpec.describe Emails::ServiceDesk do +RSpec.describe Emails::ServiceDesk, feature_category: :service_desk do include EmailSpec::Helpers include EmailSpec::Matchers include EmailHelpers @@ -16,6 +16,9 @@ RSpec.describe Emails::ServiceDesk do let_it_be(:issue) { create(:issue, project: project) } let_it_be(:email) { 'someone@gitlab.com' } let_it_be(:expected_unsubscribe_url) { unsubscribe_sent_notification_url('b7721fc7e8419911a8bea145236a0519') } + let_it_be(:credential) { create(:service_desk_custom_email_credential, project: project) } + let_it_be(:verification) { create(:service_desk_custom_email_verification, project: project) } + let_it_be(:service_desk_setting) { create(:service_desk_setting, project: project, custom_email: 'user@example.com') } let(:template) { double(content: template_content) } @@ -81,6 +84,24 @@ RSpec.describe Emails::ServiceDesk do end end + shared_examples 'a custom email verification process email' do + it 'contains custom email and project in subject' do + expect(subject.subject).to include(service_desk_setting.custom_email) + expect(subject.subject).to include(service_desk_setting.project.name) + end + end + + shared_examples 'a custom email verification process notification email' do + it 'has correct recipient' do + expect(subject.to).to eq(['owner@example.com']) + end + + it 'contains custom email and project in body' do + is_expected.to have_body_text(service_desk_setting.custom_email) + is_expected.to have_body_text(service_desk_setting.project.name) + end + end + describe '.service_desk_thank_you_email' do let_it_be(:reply_in_subject) { true } let_it_be(:default_text) do @@ -305,4 +326,20 @@ RSpec.describe Emails::ServiceDesk do end end end + + describe '.service_desk_verification_triggered_email' do + before do + service_desk_setting.custom_email_verification.triggerer = user + end + + subject { Notify.service_desk_verification_triggered_email(service_desk_setting, 'owner@example.com') } + + it_behaves_like 'an email sent from GitLab' + it_behaves_like 'a custom email verification process email' + it_behaves_like 'a custom email verification process notification email' + + it 'contains triggerer username' do + is_expected.to have_body_text("@#{user.username}") + end + end end |