diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:07:52 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-04 12:07:52 +0000 |
commit | c6c7437861bff9572747674095c4dfbdfbea4988 (patch) | |
tree | 237d1ed922193f19ae326923457344c082003788 /spec/lib/gitlab/lograge | |
parent | d80f3cd75e700b6e62910865bfd36734644ffa89 (diff) | |
download | gitlab-ce-c6c7437861bff9572747674095c4dfbdfbea4988.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/lib/gitlab/lograge')
-rw-r--r-- | spec/lib/gitlab/lograge/custom_options_spec.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/spec/lib/gitlab/lograge/custom_options_spec.rb b/spec/lib/gitlab/lograge/custom_options_spec.rb new file mode 100644 index 00000000000..48d06283b7a --- /dev/null +++ b/spec/lib/gitlab/lograge/custom_options_spec.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe Gitlab::Lograge::CustomOptions do + describe '.call' do + let(:params) do + { + 'controller' => 'ApplicationController', + 'action' => 'show', + 'format' => 'html', + 'a' => 'b' + } + end + + let(:event) do + ActiveSupport::Notifications::Event.new( + 'test', + 1, + 2, + 'transaction_id', + { params: params, user_id: 'test' } + ) + end + + subject { described_class.call(event) } + + it 'ignores some parameters' do + param_keys = subject[:params].map { |param| param[:key] } + + expect(param_keys).not_to include(*described_class::IGNORE_PARAMS) + end + + it 'formats the parameters' do + expect(subject[:params]).to eq([{ key: 'a', value: 'b' }]) + end + + it 'adds the current time' do + travel_to(5.days.ago) do + expected_time = Time.now.utc.iso8601(3) + + expect(subject[:time]).to eq(expected_time) + end + end + + it 'adds the user id' do + expect(subject[:user_id]).to eq('test') + end + end +end |