From 65d1dfdb1c686c4235bb3548552f00f251150619 Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Mon, 26 Dec 2022 13:28:27 -0500 Subject: [PATCH 1/4] Adds Ruby 3.2 to the CI matrix. Updates checkout action version. --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2ad427d..0cb2548d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,10 +22,10 @@ jobs: strategy: fail-fast: false matrix: - ruby: ["3.1", "3.0", "2.7", "2.6"] + ruby: ["3.2", "3.1", "3.0", "2.7", "2.6"] redis: ["5.x"] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} From 6837d8a22f2372031f020a02516be10207e02ea3 Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Mon, 26 Dec 2022 13:47:53 -0500 Subject: [PATCH 2/4] Switch 127.0.0.1 to localhost so specs pass. --- spec/lib/storage/redis_store_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/lib/storage/redis_store_spec.rb b/spec/lib/storage/redis_store_spec.rb index 6b132fe5..447475be 100644 --- a/spec/lib/storage/redis_store_spec.rb +++ b/spec/lib/storage/redis_store_spec.rb @@ -153,7 +153,7 @@ describe 'diagnostics' do it "returns useful info" do res = store.diagnostics('a') - expected = "Redis prefix: MPRedisStore\nRedis location: 127.0.0.1:6379 db: 2\nunviewed_ids: []\n" + expected = "Redis prefix: MPRedisStore\nRedis location: localhost:6379 db: 2\nunviewed_ids: []\n" expect(res).to eq(expected) end end From 33e70efc287f5aa0bf0ba19b404e5154ade169fd Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Mon, 26 Dec 2022 14:13:04 -0500 Subject: [PATCH 3/4] Address lints. Disable context wording --- .rubocop.yml | 3 +++ spec/lib/profiler_spec.rb | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3d575f38..f9594b80 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,6 +1,9 @@ inherit_gem: rubocop-discourse: default.yml +RSpec/ContextWording: + Enabled: false + RSpec/MessageSpies: Enabled: false diff --git a/spec/lib/profiler_spec.rb b/spec/lib/profiler_spec.rb index eabe33ed..0a4d351b 100644 --- a/spec/lib/profiler_spec.rb +++ b/spec/lib/profiler_spec.rb @@ -100,7 +100,7 @@ def self.bar(baz, boo) end describe 'typical usage' do - before(:all) do + before do start = Process.clock_gettime(Process::CLOCK_MONOTONIC) clock_set(start) Rack::MiniProfiler.create_current @@ -122,7 +122,7 @@ def self.bar(baz, boo) @inner = @outer.children[0] end - after(:all) do + after do clock_back_to_normal end From d3e074d9ec3be50c634eed93570baf628ff5361e Mon Sep 17 00:00:00 2001 From: Peter Goldstein Date: Mon, 27 Mar 2023 18:23:43 -0400 Subject: [PATCH 4/4] Fix lint. --- lib/mini_profiler/profiler.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/mini_profiler/profiler.rb b/lib/mini_profiler/profiler.rb index 674b8433..96d518d7 100644 --- a/lib/mini_profiler/profiler.rb +++ b/lib/mini_profiler/profiler.rb @@ -347,12 +347,7 @@ def call(env) env['HTTP_ACCEPT_ENCODING'] = 'identity' if config.suppress_encoding if query_string =~ /pp=(async-)?flamegraph/ || env['HTTP_REFERER'] =~ /pp=async-flamegraph/ - unless defined?(StackProf) && StackProf.respond_to?(:run) - headers = { 'Content-Type' => 'text/html' } - message = "Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile" - body.close if body.respond_to? :close - return client_settings.handle_cookie([500, headers, message]) - else + if defined?(StackProf) && StackProf.respond_to?(:run) # do not sully our profile with mini profiler timings current.measure = false match_data = query_string.match(/flamegraph_sample_rate=([\d\.]+)/) @@ -379,6 +374,11 @@ def call(env) ) do status, headers, body = @app.call(env) end + else + headers = { 'Content-Type' => 'text/html' } + message = "Please install the stackprof gem and require it: add gem 'stackprof' to your Gemfile" + body.close if body.respond_to? :close + return client_settings.handle_cookie([500, headers, message]) end elsif path == '/rack-mini-profiler/requests' blank_page_html = <<~HTML