mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Missing key should throw KeyError
It should not throw a NameError, but should throw a KeyError. Fixes #26278
This commit is contained in:
parent
f394f3ba76
commit
1ec85cf9d8
2 changed files with 7 additions and 1 deletions
|
@ -86,7 +86,7 @@ module ActionDispatch
|
|||
@req.fetch_header(env_name(key)) do
|
||||
return default unless default == DEFAULT
|
||||
return yield if block_given?
|
||||
raise NameError, key
|
||||
raise KeyError, key
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -158,4 +158,10 @@ class HeaderTest < ActiveSupport::TestCase
|
|||
assert_equal({ "HTTP_REFERER"=>"http://example.com/",
|
||||
"CONTENT_TYPE"=>"text/plain" }, env)
|
||||
end
|
||||
|
||||
test "fetch exception" do
|
||||
assert_raises KeyError do
|
||||
@headers.fetch(:some_key_that_doesnt_exist)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue