This commit is contained in:
Nicholas La Roux 2026-03-27 09:20:02 +00:00 committed by GitHub
commit 35cb883717
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 11 deletions

View File

@ -52,11 +52,17 @@ RSpec.describe RequestPool do
end
it 'closes the connections' do
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
notifications = capture_notifications('with.request_pool') do
subject.with('http://example.com') do |http_client|
http_client.get('/').flush
end
end
expect { reaper_observes_idle_timeout }.to change(subject, :size).from(1).to(0)
expect(notifications.size).to eq(1)
expect(notifications.first.payload[:host]).to eq('http://example.com')
expect(notifications.first.payload[:miss]).to be(true)
end
def reaper_observes_idle_timeout

View File

@ -36,14 +36,12 @@ RSpec.describe Setting do
context 'when the setting has been saved to database' do
it 'returns the value from database' do
callback = double
allow(callback).to receive(:call)
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
notifications = capture_notifications('sql.active_record') do
expect(described_class[key]).to eq 42
end
expect(callback).to have_received(:call)
expect(notifications.size).to eq(1)
expect(notifications.first.payload[:name]).to eq('Setting Load')
end
end
@ -62,12 +60,11 @@ RSpec.describe Setting do
end
it 'does not query the database' do
callback = double
allow(callback).to receive(:call)
ActiveSupport::Notifications.subscribed callback, 'sql.active_record' do
notifications = capture_notifications('sql.active_record') do
described_class[key]
end
expect(callback).to_not have_received(:call)
expect(notifications).to be_empty
end
it 'returns the cached value' do

View File

@ -108,6 +108,7 @@ RSpec.configure do |config|
config.include Devise::Test::IntegrationHelpers, type: :request
config.include ActionMailer::TestHelper
config.include Paperclip::Shoulda::Matchers
config.include ActiveSupport::Testing::NotificationAssertions
config.include ActiveSupport::Testing::TimeHelpers
config.include Chewy::Rspec::Helpers
config.include Redisable