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
path: root/spec/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2019-08-01 01:38:02 +0300
committerStan Hu <stanhu@gmail.com>2019-08-01 01:47:19 +0300
commit7a5c4cd0ca692e2fac0d648726b71dcd304602ec (patch)
tree8298693dda0fd46eb10271636f8f6c64ed74d5bd /spec/lib
parentce77d137abcc8e21844fdee54620d95d7b626983 (diff)
Fix SystemStackError when Peek bar is active with Rugged calls
Peek attempts to serialize results with `to_json`, which calls `ActiveSupport::JSON`. If an object is passed to `to_json` that contains instance variables, `ActiveSupport` will attempt to recursively traverse all variables. The problem is that we can get into an infinite loop if the instance references to an instance that references to something else that points back to the same instance. To avoid this mess, we just call `to_s` on the object. It appears only `Gitlab::Git::Repository` and `::Repository` are the culprits here. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/65404
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/peek/views/rugged_spec.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/spec/lib/peek/views/rugged_spec.rb b/spec/lib/peek/views/rugged_spec.rb
index 8bf996fc6bc..d07d6b51a1f 100644
--- a/spec/lib/peek/views/rugged_spec.rb
+++ b/spec/lib/peek/views/rugged_spec.rb
@@ -24,7 +24,7 @@ describe Peek::Views::Rugged, :request_store do
args: [project.repository.raw, 'HEAD'],
duration: 0.123)
::Gitlab::RuggedInstrumentation.add_call_details(feature: :rugged_test2,
- args: [project.repository.raw, 'refs/heads/master'],
+ args: [project.repository, 'refs/heads/master'],
duration: 0.456)
results = subject.results
@@ -32,7 +32,11 @@ describe Peek::Views::Rugged, :request_store do
expect(results[:duration]).to eq('1234.00ms')
expect(results[:details].count).to eq(2)
- expect(results[:details][0][:args]).to eq([project.repository.raw.to_s, "refs/heads/master"])
- expect(results[:details][1][:args]).to eq([project.repository.raw.to_s, "HEAD"])
+ expected = [
+ [project.repository.raw.to_s, "HEAD"],
+ [project.repository.to_s, "refs/heads/master"]
+ ]
+
+ expect(results[:details].map { |data| data[:args] }).to match_array(expected)
end
end