diff options
Diffstat (limited to 'spec/models/hooks/web_hook_spec.rb')
-rw-r--r-- | spec/models/hooks/web_hook_spec.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb index ad5f01fe056..254b8c2520b 100644 --- a/spec/models/hooks/web_hook_spec.rb +++ b/spec/models/hooks/web_hook_spec.rb @@ -267,7 +267,7 @@ RSpec.describe WebHook, feature_category: :integrations do end context 'without url variables' do - subject(:hook) { build_stubbed(:project_hook, project: project, url: 'http://example.com') } + subject(:hook) { build_stubbed(:project_hook, project: project, url: 'http://example.com', url_variables: nil) } it 'does not reset url variables' do hook.url = 'http://example.com/{one}/{two}' @@ -346,7 +346,7 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'is 10 minutes' do - expect(hook.next_backoff).to eq(described_class::INITIAL_BACKOFF) + expect(hook.next_backoff).to eq(WebHooks::AutoDisabling::INITIAL_BACKOFF) end end @@ -356,7 +356,7 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'is twice the initial value' do - expect(hook.next_backoff).to eq(2 * described_class::INITIAL_BACKOFF) + expect(hook.next_backoff).to eq(2 * WebHooks::AutoDisabling::INITIAL_BACKOFF) end end @@ -366,7 +366,7 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'grows exponentially' do - expect(hook.next_backoff).to eq(2 * 2 * 2 * described_class::INITIAL_BACKOFF) + expect(hook.next_backoff).to eq(2 * 2 * 2 * WebHooks::AutoDisabling::INITIAL_BACKOFF) end end @@ -376,7 +376,7 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'does not exceed the max backoff value' do - expect(hook.next_backoff).to eq(described_class::MAX_BACKOFF) + expect(hook.next_backoff).to eq(WebHooks::AutoDisabling::MAX_BACKOFF) end end end @@ -498,13 +498,13 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'reduces to MAX_FAILURES' do - expect { hook.backoff! }.to change(hook, :recent_failures).to(described_class::MAX_FAILURES) + expect { hook.backoff! }.to change(hook, :recent_failures).to(WebHooks::AutoDisabling::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) + hook.update!(recent_failures: WebHooks::AutoDisabling::MAX_FAILURES, disabled_until: 1.hour.ago) end it 'does not change recent_failures' do @@ -514,7 +514,7 @@ RSpec.describe WebHook, feature_category: :integrations do context 'when we have exhausted the grace period' do before do - hook.update!(recent_failures: described_class::FAILURE_THRESHOLD) + hook.update!(recent_failures: WebHooks::AutoDisabling::FAILURE_THRESHOLD) end it 'sets disabled_until to the next backoff' do @@ -527,8 +527,8 @@ RSpec.describe WebHook, feature_category: :integrations do context 'when we have backed off MAX_FAILURES times' do before do - stub_const("#{described_class}::MAX_FAILURES", 5) - (described_class::FAILURE_THRESHOLD + 5).times { hook.backoff! } + stub_const("WebHooks::AutoDisabling::MAX_FAILURES", 5) + (WebHooks::AutoDisabling::FAILURE_THRESHOLD + 5).times { hook.backoff! } end it 'does not let the backoff count exceed the maximum failure count' do @@ -544,7 +544,7 @@ RSpec.describe WebHook, feature_category: :integrations do it 'changes disabled_until when it has elapsed', :skip_freeze_time do travel_to(hook.disabled_until + 1.minute) do expect { hook.backoff! }.to change { hook.disabled_until } - expect(hook.backoff_count).to eq(described_class::MAX_FAILURES) + expect(hook.backoff_count).to eq(WebHooks::AutoDisabling::MAX_FAILURES) end end end @@ -567,7 +567,7 @@ RSpec.describe WebHook, feature_category: :integrations do end it 'does not update the hook if the the failure count exceeds the maximum value' do - hook.recent_failures = described_class::MAX_FAILURES + hook.recent_failures = WebHooks::AutoDisabling::MAX_FAILURES sql_count = ActiveRecord::QueryRecorder.new { hook.failed! }.count |