Commit 50af024a authored by Luke Duncalfe's avatar Luke Duncalfe
parent bf3816f4
......@@ -92,7 +92,7 @@ class WebHook < ApplicationRecord
end
def backoff!
return if backoff_count >= MAX_FAILURES && temporarily_disabled?
return if permanently_disabled? || (backoff_count >= MAX_FAILURES && temporarily_disabled?)
assign_attributes(disabled_until: next_backoff.from_now, backoff_count: backoff_count.succ.clamp(0, MAX_FAILURES))
save(validate: false)
......
......@@ -330,6 +330,20 @@ RSpec.describe WebHook do
expect { hook.backoff! }.to change(hook, :backoff_count).by(1)
end
context 'when the hook is permanently disabled' do
before do
allow(hook).to receive(:permanently_disabled?).and_return(true)
end
it 'does not set disabled_until' do
expect { hook.backoff! }.not_to change(hook, :disabled_until)
end
it 'does not increment the backoff count' do
expect { hook.backoff! }.not_to change(hook, :backoff_count)
end
end
context 'when we have backed off MAX_FAILURES times' do
before do
stub_const("#{described_class}::MAX_FAILURES", 5)
......
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