diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-13 21:09:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-13 21:09:16 +0300 |
commit | d9aac35d79489591396456aceefa609de4b8b05c (patch) | |
tree | 3ef25ee74f8ba1a72771a519c912d5e239ff2bb8 /spec/services/notification_service_spec.rb | |
parent | ff430539d5299de3a066cb8397b302626761a745 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/notification_service_spec.rb')
-rw-r--r-- | spec/services/notification_service_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index e6b82acad55..9c837019d37 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -343,6 +343,79 @@ RSpec.describe NotificationService, :mailer do end end + context 'on service desk issue' do + before do + allow(Notify).to receive(:service_desk_new_note_email) + .with(Integer, Integer).and_return(mailer) + + allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true } + allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true } + end + + let(:subject) { NotificationService.new } + let(:mailer) { double(deliver_later: true) } + + def should_email! + expect(Notify).to receive(:service_desk_new_note_email) + .with(issue.id, note.id) + end + + def should_not_email! + expect(Notify).not_to receive(:service_desk_new_note_email) + end + + def execute! + subject.new_note(note) + end + + def self.it_should_email! + it 'sends the email' do + should_email! + execute! + end + end + + def self.it_should_not_email! + it 'doesn\'t send the email' do + should_not_email! + execute! + end + end + + let(:issue) { create(:issue, author: User.support_bot) } + let(:project) { issue.project } + let(:note) { create(:note, noteable: issue, project: project) } + + context 'a non-service-desk issue' do + it_should_not_email! + end + + context 'a service-desk issue' do + before do + issue.update!(service_desk_reply_to: 'service.desk@example.com') + project.update!(service_desk_enabled: true) + end + + it_should_email! + + context 'where the project has disabled the feature' do + before do + project.update(service_desk_enabled: false) + end + + it_should_not_email! + end + + context 'when the support bot has unsubscribed' do + before do + issue.unsubscribe(User.support_bot, project) + end + + it_should_not_email! + end + end + end + describe 'new note on issue in project that belongs to a group' do before do note.project.namespace_id = group.id |