Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-04-19 17:03:56 +0300
committerToon Claes <toon@gitlab.com>2018-05-07 10:42:09 +0300
commit6dca7b5b0d8920f2c7aaedefdb8ee1a056d7a1c2 (patch)
tree121a36af42a704f1cbf600ae7957e18ef7029e09 /spec/workers/admin_email_worker_spec.rb
parent5116b59fb33e5a4520c42a788e80bc8b76f0008f (diff)
Do not send repository check mails when they are disabled
In case the repository checks are disabled, do not send the mails. Otherwise it might send the same failures over and over again.
Diffstat (limited to 'spec/workers/admin_email_worker_spec.rb')
-rw-r--r--spec/workers/admin_email_worker_spec.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/workers/admin_email_worker_spec.rb b/spec/workers/admin_email_worker_spec.rb
new file mode 100644
index 00000000000..27687f069ea
--- /dev/null
+++ b/spec/workers/admin_email_worker_spec.rb
@@ -0,0 +1,41 @@
+require 'spec_helper'
+
+describe AdminEmailWorker do
+ subject(:worker) { described_class.new }
+
+ describe '.perform' do
+ it 'does not attempt to send repository check mail when they are disabled' do
+ stub_application_setting(repository_checks_enabled: false)
+
+ expect(worker).not_to receive(:send_repository_check_mail)
+
+ worker.perform
+ end
+
+ context 'repository_checks enabled' do
+ before do
+ stub_application_setting(repository_checks_enabled: true)
+ end
+
+ it 'checks if repository check mail should be sent' do
+ expect(worker).to receive(:send_repository_check_mail)
+
+ worker.perform
+ end
+
+ it 'does not send mail when there are no failed repos' do
+ expect(RepositoryCheckMailer).not_to receive(:notify)
+
+ worker.perform
+ end
+
+ it 'send mail when there is a failed repo' do
+ create(:project, last_repository_check_failed: true, last_repository_check_at: Date.yesterday)
+
+ expect(RepositoryCheckMailer).to receive(:notify).and_return(spy)
+
+ worker.perform
+ end
+ end
+ end
+end