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:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-23 22:44:23 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-23 22:44:23 +0300
commit6b96d119aec0ba674cca2c380cf60f1500306612 (patch)
treef7742d802f557d04e2144b06a2b47719fbd58b82 /spec/support
parent8b7c4494871c7d69ac7bc59839bdce6ff2937f95 (diff)
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/shared_contexts/controllers/logging_shared_context.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/support/shared_contexts/controllers/logging_shared_context.rb b/spec/support/shared_contexts/controllers/logging_shared_context.rb
new file mode 100644
index 00000000000..986a96f3a8d
--- /dev/null
+++ b/spec/support/shared_contexts/controllers/logging_shared_context.rb
@@ -0,0 +1,21 @@
+# frozen_string_literal: true
+
+# This context replaces the logger and exposes the `log_data` variable for
+# inspection
+RSpec.shared_context 'parsed logs' do
+ let(:logger) do
+ Logger.new(log_output).tap { |logger| logger.formatter = ->(_, _, _, msg) { msg } }
+ end
+
+ let(:log_output) { StringIO.new }
+ let(:log_data) { Gitlab::Json.parse(log_output.string) }
+
+ around do |example|
+ initial_logger = Lograge.logger
+ Lograge.logger = logger
+
+ example.run
+
+ Lograge.logger = initial_logger
+ end
+end