diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-31 03:10:12 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-31 03:10:12 +0300 |
commit | f9f496e7f19f574992b9543763490fda6d920e77 (patch) | |
tree | 3b0cf2eda897e32a3e4c8f234070b2dabc593b72 /spec/services/notification_service_spec.rb | |
parent | 7208156569518903735416b95a4a0d8f83255d41 (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 | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/spec/services/notification_service_spec.rb b/spec/services/notification_service_spec.rb index e4ad8909785..9431c023850 100644 --- a/spec/services/notification_service_spec.rb +++ b/spec/services/notification_service_spec.rb @@ -297,17 +297,17 @@ RSpec.describe NotificationService, :mailer do describe 'Notes' do context 'issue note' do let_it_be(:project) { create(:project, :private) } - let_it_be_with_reload(:issue) { create(:issue, project: project, assignees: [assignee]) } + let_it_be(:issue) { create(:issue, project: project, assignees: [assignee]) } let_it_be(:mentioned_issue) { create(:issue, assignees: issue.assignees) } let_it_be_with_reload(:author) { create(:user) } let(:note) { create(:note_on_issue, author: author, noteable: issue, project_id: issue.project_id, note: '@mention referenced, @unsubscribed_mentioned and @outsider also') } subject { notification.new_note(note) } - context 'issue_email_participants' do + context 'on service desk issue' do before do allow(Notify).to receive(:service_desk_new_note_email) - .with(Integer, Integer, String).and_return(mailer) + .with(Integer, Integer).and_return(mailer) allow(::Gitlab::IncomingEmail).to receive(:enabled?) { true } allow(::Gitlab::IncomingEmail).to receive(:supports_wildcard?) { true } @@ -318,7 +318,7 @@ RSpec.describe NotificationService, :mailer do def should_email! expect(Notify).to receive(:service_desk_new_note_email) - .with(issue.id, note.id, issue.external_author) + .with(issue.id, note.id) end def should_not_email! @@ -347,19 +347,33 @@ RSpec.describe NotificationService, :mailer do let(:project) { issue.project } let(:note) { create(:note, noteable: issue, project: project) } - context 'do not exist' do + context 'a non-service-desk issue' do it_should_not_email! end - context 'do exist' do - let!(:issue_email_participant) { issue.issue_email_participants.create!(email: 'service.desk@example.com') } - + context 'a service-desk issue' do before do issue.update!(external_author: '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 |