Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove setting quiet requests inside puma rack handler #2075

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions History.md
Expand Up @@ -3,6 +3,7 @@
* Features
* Add pumactl `thread-backtraces` command to print thread backtraces (#2053)
* Configuration: `environment` is read from `RAILS_ENV`, if `RACK_ENV` can't be found (#2022)
* Do not set user_config to quiet by default to allow for file config (#2074)

* Bugfixes
* Your bugfix goes here (#Github Number)
Expand Down
2 changes: 0 additions & 2 deletions lib/rack/handler/puma.rb
Expand Up @@ -30,8 +30,6 @@ def self.config(app, options = {})
end

conf = ::Puma::Configuration.new(options, default_options) do |user_config, file_config, default_config|
user_config.quiet

if options.delete(:Verbose)
app = Rack::CommonLogger.new(app, STDOUT)
end
Expand Down
35 changes: 35 additions & 0 deletions test/test_rack_handler.rb
Expand Up @@ -226,4 +226,39 @@ def test_user_port_wins_over_config
end
end
end

def test_file_log_requests_wins_over_deafult_config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo default

file_log_requests_config = true

Dir.mktmpdir do |d|
Dir.chdir(d) do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather just have a new, pre-baked config file on the filesystem, rather than create it dynamically. That way we can run the test in parallel.

FileUtils.mkdir("config")
File.open("config/puma.rb", "w") { |f| f << "log_requests #{file_log_requests_config}" }

conf = Rack::Handler::Puma.config(->{}, @options)
conf.load

assert_equal file_log_requests_config, conf.options[:log_requests]
end
end
end


def test_user_log_requests_wins_over_file_config
file_log_requests_config = true
user_log_requests_config = false

Dir.mktmpdir do |d|
Dir.chdir(d) do
FileUtils.mkdir("config")
File.open("config/puma.rb", "w") { |f| f << "log_requests #{file_log_requests_config}" }

@options[:log_requests] = user_log_requests_config
conf = Rack::Handler::Puma.config(->{}, @options)
conf.load

assert_equal user_log_requests_config, conf.options[:log_requests]
end
end
end
end