Skip to content

Commit

Permalink
Add CHANGELOG entry for #1034
Browse files Browse the repository at this point in the history
Also changed the error messagen and the implementation to use `#fetch`.
  • Loading branch information
rafaelfranca committed Sep 27, 2018
1 parent b40583b commit 5559676
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file. For info on
- CHANGELOG.md using keep a changelog formatting by @twitnithegirl

### Changed
- `Rack::Utils.status_code` now raises an error when the status symbol is invalid instead of `500`.

### Removed
- HISTORY.md by @twitnithegirl
Expand Down
3 changes: 1 addition & 2 deletions lib/rack/utils.rb
Expand Up @@ -563,8 +563,7 @@ def names

def status_code(status)
if status.is_a?(Symbol)
raise ArgumentError, "Unrecognized status_code symbol" unless SYMBOL_TO_STATUS_CODE[status]
SYMBOL_TO_STATUS_CODE[status]
SYMBOL_TO_STATUS_CODE.fetch(status) { raise ArgumentError, "Unrecognized status code #{status.inspect}" }
else
status.to_i
end
Expand Down
2 changes: 1 addition & 1 deletion test/spec_utils.rb
Expand Up @@ -463,7 +463,7 @@ def initialize(*)
end

it "raise an error for an invalid symbol" do
assert_raises(ArgumentError, "Unrecognized status_code symbol") do
assert_raises(ArgumentError, "Unrecognized status code :foobar") do
Rack::Utils.status_code(:foobar)
end
end
Expand Down

0 comments on commit 5559676

Please sign in to comment.