mirror of
https://github.com/mastodon/mastodon.git
synced 2026-09-08 04:15:49 -05:00
Migrate a few tests to use NotificationAssertions (#38098)
Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Some checks are pending
Bundler Audit / security (push) Waiting to run
Check i18n / check-i18n (push) Waiting to run
Chromatic / Check for relevant changes (push) Waiting to run
Chromatic / Run Chromatic (push) Blocked by required conditions
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
CSS Linting / lint (push) Waiting to run
Haml Linting / lint (push) Waiting to run
JavaScript Linting / lint (push) Waiting to run
Ruby Linting / lint (push) Waiting to run
JavaScript Testing / test (push) Waiting to run
Historical data migration test / test (14-alpine) (push) Waiting to run
Historical data migration test / test (15-alpine) (push) Waiting to run
Historical data migration test / test (16-alpine) (push) Waiting to run
Historical data migration test / test (17-alpine) (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / test (3.4) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.4) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.19.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.4, docker.elastic.co/elasticsearch/elasticsearch:7.17.29) (push) Blocked by required conditions
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -82,6 +82,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
|
||||
|
||||
Reference in New Issue
Block a user