mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #26589 from kirs/ad-test-request-method
Fix memoization bug on ActionDispatch::TestRequest#request_method=
This commit is contained in:
commit
f08bb28702
2 changed files with 8 additions and 1 deletions
|
@ -22,7 +22,7 @@ module ActionDispatch
|
|||
private_class_method :default_env
|
||||
|
||||
def request_method=(method)
|
||||
set_header("REQUEST_METHOD", method.to_s.upcase)
|
||||
super(method.to_s.upcase)
|
||||
end
|
||||
|
||||
def host=(host)
|
||||
|
|
|
@ -88,6 +88,13 @@ class TestRequestTest < ActiveSupport::TestCase
|
|||
assert_equal "GoogleBot", req.user_agent
|
||||
end
|
||||
|
||||
test "request_method getter and setter" do
|
||||
req = ActionDispatch::TestRequest.create
|
||||
req.request_method # to reproduce bug caused by memoization
|
||||
req.request_method = "POST"
|
||||
assert_equal "POST", req.request_method
|
||||
end
|
||||
|
||||
test "setter methods" do
|
||||
req = ActionDispatch::TestRequest.create({})
|
||||
get = "GET"
|
||||
|
|
Loading…
Reference in a new issue