Skip to content

Commit

Permalink
Don't emit warning message when mapped symbol exists. (#2209)
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Jun 12, 2024
1 parent d43ab86 commit 4f81703
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/rack/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,11 @@ def status_code(status)
fallback_code = OBSOLETE_SYMBOLS_TO_STATUS_CODES.fetch(status) { raise ArgumentError, "Unrecognized status code #{status.inspect}" }
message = "Status code #{status.inspect} is deprecated and will be removed in a future version of Rack."
if canonical_symbol = OBSOLETE_SYMBOL_MAPPINGS[status]
message = "#{message} Please use #{canonical_symbol.inspect} instead."
# message = "#{message} Please use #{canonical_symbol.inspect} instead."
# For now, let's not emit any warning when there is a mapping.
else
warn message, uplevel: 3
end
warn message, uplevel: 1
fallback_code
end
else
Expand Down
4 changes: 2 additions & 2 deletions test/spec_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -538,12 +538,12 @@ def initialize(*)
capture_warnings(Rack::Utils) do |warnings|
replaced_statuses.each do |symbol, value_hash|
Rack::Utils.status_code(symbol).must_equal value_hash[:status_code]
warnings.pop.must_equal ["Status code #{symbol.inspect} is deprecated and will be removed in a future version of Rack. Please use #{value_hash[:standard_symbol].inspect} instead.", { uplevel: 1 }]
warnings.must_be_empty
end

dropped_statuses.each do |symbol, code|
Rack::Utils.status_code(symbol).must_equal code
warnings.pop.must_equal ["Status code #{symbol.inspect} is deprecated and will be removed in a future version of Rack.", { uplevel: 1 }]
warnings.pop.must_equal ["Status code #{symbol.inspect} is deprecated and will be removed in a future version of Rack.", { uplevel: 3 }]
end
end
end
Expand Down

0 comments on commit 4f81703

Please sign in to comment.