Commit 6b17c467 authored by Rémy Coutable's avatar Rémy Coutable

Make some examples faster in NotificationService specs

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent da9e55a0
...@@ -394,7 +394,7 @@ describe NotificationService, :mailer do ...@@ -394,7 +394,7 @@ describe NotificationService, :mailer do
end end
end end
context 'confidential issue note', :deliver_mails_inline do context 'confidential issue note' do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:assignee) { create(:user) } let(:assignee) { create(:user) }
...@@ -406,23 +406,22 @@ describe NotificationService, :mailer do ...@@ -406,23 +406,22 @@ describe NotificationService, :mailer do
let(:note) { create(:note_on_issue, noteable: confidential_issue, project: project, note: "#{author.to_reference} #{assignee.to_reference} #{non_member.to_reference} #{member.to_reference} #{admin.to_reference}") } let(:note) { create(:note_on_issue, noteable: confidential_issue, project: project, note: "#{author.to_reference} #{assignee.to_reference} #{non_member.to_reference} #{member.to_reference} #{admin.to_reference}") }
let(:guest_watcher) { create_user_with_notification(:watch, "guest-watcher-confidential") } let(:guest_watcher) { create_user_with_notification(:watch, "guest-watcher-confidential") }
it 'filters out users that can not read the issue' do subject { notification.new_note(note) }
before do
project.add_developer(member) project.add_developer(member)
project.add_guest(guest) project.add_guest(guest)
expect(SentNotification).to receive(:record).with(confidential_issue, any_args).exactly(4).times
reset_delivered_emails! reset_delivered_emails!
end
notification.new_note(note) it 'filters out users that can not read the issue' do
subject
should_not_email(non_member) expect_delivery_jobs_count(4)
should_not_email(guest) expect_enqueud_email(author.id, note.id, "mentioned", mail: "note_issue_email")
should_not_email(guest_watcher) expect_enqueud_email(assignee.id, note.id, "mentioned", mail: "note_issue_email")
should_email(author) expect_enqueud_email(member.id, note.id, "mentioned", mail: "note_issue_email")
should_email(assignee) expect_enqueud_email(admin.id, note.id, "mentioned", mail: "note_issue_email")
should_email(member)
should_email(admin)
end end
context 'on project that belongs to subgroup' do context 'on project that belongs to subgroup' do
...@@ -442,10 +441,10 @@ describe NotificationService, :mailer do ...@@ -442,10 +441,10 @@ describe NotificationService, :mailer do
end end
it 'does not email guest user' do it 'does not email guest user' do
notification.new_note(note) subject
should_email(group_reporter) expect_enqueud_email(group_reporter.id, note.id, nil, mail: "note_issue_email")
should_not_email(group_guest) expect_not_enqueud_email(group_guest.id, "mentioned", mail: "note_issue_email")
end end
end end
end end
......
...@@ -57,7 +57,7 @@ module NotificationHelpers ...@@ -57,7 +57,7 @@ module NotificationHelpers
expect(ActionMailer::DeliveryJob).to have_been_enqueued.with(mailer, mail, delivery, *args) expect(ActionMailer::DeliveryJob).to have_been_enqueued.with(mailer, mail, delivery, *args)
end end
def expect_not_enqueud_email(*args, mailer: "Notify", mail: "", delivery: "deliver_now") def expect_not_enqueud_email(*args, mailer: "Notify", mail: "")
expect(ActionMailer::DeliveryJob).not_to have_been_enqueued.with(mailer, mail, *args, any_args) expect(ActionMailer::DeliveryJob).not_to have_been_enqueued.with(mailer, mail, *args, any_args)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment