summaryrefslogtreecommitdiff
path: root/spec/models/hooks
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-10-21 12:11:29 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-10-21 12:11:29 +0000
commit559b1da28e46a9969315beb11ee2d2056f75b06d (patch)
treefad20c706047f4aca44c1f030cb81d5b1e302cab /spec/models/hooks
parenta065770457b66dc856897fc5282bf897b9e4f65b (diff)
downloadgitlab-ce-559b1da28e46a9969315beb11ee2d2056f75b06d.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/hooks')
-rw-r--r--spec/models/hooks/web_hook_spec.rb34
1 files changed, 32 insertions, 2 deletions
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb
index dd5bf8b99dd..3ca41e613fa 100644
--- a/spec/models/hooks/web_hook_spec.rb
+++ b/spec/models/hooks/web_hook_spec.rb
@@ -446,7 +446,7 @@ RSpec.describe WebHook do
end
end
- describe 'backoff!' do
+ describe '#backoff!' do
context 'when we have not backed off before' do
it 'does not disable the hook' do
expect { hook.backoff! }.not_to change(hook, :executable?).from(true)
@@ -457,6 +457,26 @@ RSpec.describe WebHook do
end
end
+ context 'when the recent failure value is the max value of a smallint' do
+ before do
+ hook.update!(recent_failures: 32767, disabled_until: 1.hour.ago)
+ end
+
+ it 'reduces to MAX_FAILURES' do
+ expect { hook.backoff! }.to change(hook, :recent_failures).to(described_class::MAX_FAILURES)
+ end
+ end
+
+ context 'when the recent failure value is MAX_FAILURES' do
+ before do
+ hook.update!(recent_failures: described_class::MAX_FAILURES, disabled_until: 1.hour.ago)
+ end
+
+ it 'does not change recent_failures' do
+ expect { hook.backoff! }.not_to change(hook, :recent_failures)
+ end
+ end
+
context 'when we have exhausted the grace period' do
before do
hook.update!(recent_failures: described_class::FAILURE_THRESHOLD)
@@ -516,11 +536,21 @@ RSpec.describe WebHook do
end
end
- describe 'failed!' do
+ describe '#failed!' do
it 'increments the failure count' do
expect { hook.failed! }.to change(hook, :recent_failures).by(1)
end
+ context 'when the recent failure value is the max value of a smallint' do
+ before do
+ hook.update!(recent_failures: 32767)
+ end
+
+ it 'does not change recent_failures' do
+ expect { hook.failed! }.not_to change(hook, :recent_failures)
+ end
+ end
+
it 'does not update the hook if the the failure count exceeds the maximum value' do
hook.recent_failures = described_class::MAX_FAILURES