diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 09:08:32 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-24 09:08:32 +0000 |
commit | 9b984f55eef568b6a15c3a125e0cf66f35678e5a (patch) | |
tree | ee7e1eb42f27400dd74bb44bb595263af2d72fc1 /spec/support/helpers | |
parent | 83a9f472b8b523619519a1834176165c9f1532f7 (diff) | |
download | gitlab-ce-9b984f55eef568b6a15c3a125e0cf66f35678e5a.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/support/helpers')
-rw-r--r-- | spec/support/helpers/email_helpers.rb | 5 | ||||
-rw-r--r-- | spec/support/helpers/notification_helpers.rb | 24 |
2 files changed, 29 insertions, 0 deletions
diff --git a/spec/support/helpers/email_helpers.rb b/spec/support/helpers/email_helpers.rb index 024340310a1..6df33e68629 100644 --- a/spec/support/helpers/email_helpers.rb +++ b/spec/support/helpers/email_helpers.rb @@ -6,7 +6,12 @@ module EmailHelpers end def reset_delivered_emails! + # We shouldn't actually send the emails, but we keep the following line for + # back-compatibility until we only check the mailer jobs enqueued in Sidekiq ActionMailer::Base.deliveries.clear + # We should only check that the mailer jobs are enqueued in Sidekiq, hence + # clearing the background jobs queue + ActiveJob::Base.queue_adapter.enqueued_jobs.clear end def should_only_email(*users, kind: :to) diff --git a/spec/support/helpers/notification_helpers.rb b/spec/support/helpers/notification_helpers.rb index 16ecb338f6e..aee76b8be4a 100644 --- a/spec/support/helpers/notification_helpers.rb +++ b/spec/support/helpers/notification_helpers.rb @@ -36,4 +36,28 @@ module NotificationHelpers setting = user.notification_settings_for(resource) setting.update!(event => value) end + + def expect_delivery_jobs_count(count) + expect(ActionMailer::DeliveryJob).to have_been_enqueued.exactly(count).times + end + + def expect_no_delivery_jobs + expect(ActionMailer::DeliveryJob).not_to have_been_enqueued + end + + def expect_any_delivery_jobs + expect(ActionMailer::DeliveryJob).to have_been_enqueued.at_least(:once) + end + + def have_enqueued_email(*args, mailer: "Notify", mail: "", delivery: "deliver_now") + have_enqueued_job(ActionMailer::DeliveryJob).with(mailer, mail, delivery, *args) + end + + def expect_enqueud_email(*args, mailer: "Notify", mail: "", delivery: "deliver_now") + expect(ActionMailer::DeliveryJob).to have_been_enqueued.with(mailer, mail, delivery, *args) + end + + def expect_not_enqueud_email(*args, mailer: "Notify", mail: "", delivery: "deliver_now") + expect(ActionMailer::DeliveryJob).not_to have_been_enqueued.with(mailer, mail, *args, any_args) + end end |