Fix bug with setting Request#format= after the getter has cached the value. Closes #10889 [cch1]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8811 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
Rick Olson 2008-02-07 16:46:50 +00:00
parent 689e27567e
commit 8e6638afa4
3 changed files with 10 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Fix bug with setting Request#format= after the getter has cached the value. #10889 [cch1]
* Correct inconsistencies in RequestForgeryProtection docs. #11032 [mislav]
* Introduce a Template class to ActionView. #11024 [lifofifo]

View File

@ -113,7 +113,7 @@ module ActionController
# end
def format=(extension)
parameters[:format] = extension.to_s
format
@format = Mime::Type.lookup_by_extension(parameters[:format])
end
# Returns true if the request's "X-Requested-With" header contains

View File

@ -371,6 +371,13 @@ class RequestTest < Test::Unit::TestCase
assert_equal Mime::HTML, @request.content_type
end
def test_format_assignment_should_set_format
@request.instance_eval { self.format = :txt }
assert !@request.format.xml?
@request.instance_eval { self.format = :xml }
assert @request.format.xml?
end
def test_content_no_type
assert_equal nil, @request.content_type
end