diff options
Diffstat (limited to 'spec/initializers/lograge_spec.rb')
-rw-r--r-- | spec/initializers/lograge_spec.rb | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb index de722764bf4..d5f9ef569c7 100644 --- a/spec/initializers/lograge_spec.rb +++ b/spec/initializers/lograge_spec.rb @@ -153,32 +153,22 @@ RSpec.describe 'lograge', type: :request do end end - context 'with transaction' do - let(:transaction) { Gitlab::Metrics::WebTransaction.new({}) } - - before do - allow(Gitlab::Metrics::Transaction).to receive(:current).and_return(transaction) - end - + context 'with db payload' do context 'when RequestStore is enabled', :request_store do - context 'with db payload' do - it 'includes db counters', :request_store do - ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') - subscriber.process_action(event) + it 'includes db counters' do + ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') + subscriber.process_action(event) - expect(log_data).to include("db_count" => 1, "db_write_count" => 0, "db_cached_count" => 0) - end + expect(log_data).to include("db_count" => a_value >= 1, "db_write_count" => 0, "db_cached_count" => 0) end end context 'when RequestStore is disabled' do - context 'with db payload' do - it 'does not include db counters' do - ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') - subscriber.process_action(event) + it 'does not include db counters' do + ActiveRecord::Base.connection.execute('SELECT pg_sleep(0.1);') + subscriber.process_action(event) - expect(log_data).not_to include("db_count" => 1, "db_write_count" => 0, "db_cached_count" => 0) - end + expect(log_data).not_to include("db_count", "db_write_count", "db_cached_count") end end end |