diff options
Diffstat (limited to 'spec/initializers')
-rw-r--r-- | spec/initializers/lograge_spec.rb | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/spec/initializers/lograge_spec.rb b/spec/initializers/lograge_spec.rb index 65652468d93..7c61d034ac9 100644 --- a/spec/initializers/lograge_spec.rb +++ b/spec/initializers/lograge_spec.rb @@ -94,6 +94,11 @@ describe 'lograge', type: :request do let(:logger) do Logger.new(log_output).tap { |logger| logger.formatter = ->(_, _, _, msg) { msg } } end + let(:log_data) { JSON.parse(log_output.string) } + + before do + Lograge.logger = logger + end describe 'with an exception' do let(:exception) { RuntimeError.new('bad request') } @@ -102,18 +107,29 @@ describe 'lograge', type: :request do before do allow(exception).to receive(:backtrace).and_return(backtrace) event.payload[:exception_object] = exception - Lograge.logger = logger end it 'adds exception data to log' do subscriber.process_action(event) - log_data = JSON.parse(log_output.string) - expect(log_data['exception.class']).to eq('RuntimeError') expect(log_data['exception.message']).to eq('bad request') expect(log_data['exception.backtrace']).to eq(Gitlab::BacktraceCleaner.clean_backtrace(backtrace)) end end + + describe 'with etag_route' do + let(:etag_route) { 'etag route' } + + before do + event.payload[:etag_route] = etag_route + end + + it 'adds etag_route to log' do + subscriber.process_action(event) + + expect(log_data['etag_route']).to eq(etag_route) + end + end end end |