Skip to content

Commit

Permalink
Quick fix for "undefined local variable or method `query_string (#597)
Browse files Browse the repository at this point in the history
* fix for undefined
  local variable or method `query_string'

* Add spec/dependency for memory_profiler
  • Loading branch information
braindeaf committed Dec 7, 2023
1 parent b550ed3 commit 3c03459
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -8,6 +8,7 @@ gemspec
group :test do
gem 'codecov', require: false
gem 'stackprof', require: false
gem 'memory_profiler', require: false
end

group :development do
Expand Down
2 changes: 1 addition & 1 deletion lib/mini_profiler/actions.rb
Expand Up @@ -133,7 +133,7 @@ def serve_profile_memory(env, client_settings)
)
end

query_params = Rack::Utils.parse_nested_query(query_string)
query_params = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
options = {
ignore_files: query_params['memory_profiler_ignore_files'],
allow_files: query_params['memory_profiler_allow_files'],
Expand Down
28 changes: 28 additions & 0 deletions spec/integration/mini_profiler_spec.rb
Expand Up @@ -141,6 +141,34 @@ def app
end
end

it 'works with memory_profiler' do
pid = fork do # Avoid polluting main process with stackprof
require 'memory_profiler'

# Should store flamegraph for ?pp=profile-memory
Rack::MiniProfiler.config.enable_advanced_debugging_tools = true
get '/html?pp=profile-memory'
expect(last_response).to be_ok
expect(last_response.body).to match(/allocated memory by gem/)
expect(last_response.body).to match(/allocated memory by file/)
expect(last_response.body).to match(/allocated memory by location/)
expect(last_response.body).to match(/allocated memory by class/)
expect(last_response.body).to match(/allocated objects by gem/)
expect(last_response.body).to match(/allocated objects by file/)
expect(last_response.body).to match(/allocated objects by location/)
expect(last_response.body).to match(/allocated objects by class/)
expect(last_response.body).to match(/retained objects by gem/)
expect(last_response.body).to match(/retained objects by file/)
expect(last_response.body).to match(/retained objects by location/)
expect(last_response.body).to match(/retained objects by class/)
expect(last_response.body).to match(/Allocated String Report/)
expect(last_response.body).to match(/Retained String Report/)
end

Process.wait(pid)
expect($?.exitstatus).to eq(0)
end

it 'works with async-flamegraph' do
pid = fork do # Avoid polluting main process with stackprof
require 'stackprof'
Expand Down

0 comments on commit 3c03459

Please sign in to comment.