Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb')
-rw-r--r--spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb b/spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb
index cb06c9fa596..3e9c4a5eb68 100644
--- a/spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb
+++ b/spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb
@@ -15,6 +15,22 @@ RSpec.shared_examples 'storing arguments in the application context' do
end
end
+# For the API we need a slightly different approach as `client_id` is
+# calculated in API logging code.
+RSpec.shared_examples 'storing arguments in the application context for the API' do
+ it 'places the expected params in the application context' do
+ expect(::API::API::LOG_FORMATTER).to receive(:call) do
+ expect(Gitlab::ApplicationContext.current).to include(log_hash(expected_params))
+ end
+
+ subject
+ end
+
+ def log_hash(hash)
+ hash.transform_keys! { |key| "meta.#{key}" }
+ end
+end
+
RSpec.shared_examples 'not executing any extra queries for the application context' do |expected_extra_queries = 0|
it 'does not execute more queries than without adding anything to the application context' do
# Call the subject once to memoize all factories being used for the spec, so they won't