Commit da19b619 authored by Luke Duncalfe's avatar Luke Duncalfe

Tidup WebHook specs

This makes two tweaks to the WebHook specs that were added in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66876

We intended to ship it using QueryRecord rather than `be_persisted:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66876/diffs#note_636790953

And also removed an unneeded `aggregate_failures`.
parent a20f106e
...@@ -289,7 +289,7 @@ RSpec.describe WebHook do ...@@ -289,7 +289,7 @@ RSpec.describe WebHook do
expect { hook.enable! }.to change(hook, :executable?).from(false).to(true) expect { hook.enable! }.to change(hook, :executable?).from(false).to(true)
end end
it 'does not update hooks unless necessary', :aggregate_failures do it 'does not update hooks unless necessary' do
sql_count = ActiveRecord::QueryRecorder.new { hook.enable! }.count sql_count = ActiveRecord::QueryRecorder.new { hook.enable! }.count
expect(sql_count).to eq(0) expect(sql_count).to eq(0)
...@@ -331,11 +331,12 @@ RSpec.describe WebHook do ...@@ -331,11 +331,12 @@ RSpec.describe WebHook do
expect { hook.failed! }.to change(hook, :recent_failures).by(1) expect { hook.failed! }.to change(hook, :recent_failures).by(1)
end end
it 'does not allow the failure count to exceed the maximum value', :aggregate_failures do 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 = described_class::MAX_FAILURES
expect { hook.failed! }.not_to change(hook, :recent_failures) sql_count = ActiveRecord::QueryRecorder.new { hook.failed! }.count
expect(hook).not_to be_persisted
expect(sql_count).to eq(0)
end end
include_examples 'is tolerant of invalid records' do include_examples 'is tolerant of invalid records' do
......
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