Permalink
Browse files

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
  • Loading branch information...
1 parent 689e275 commit 8e6638afa4b9fe7a361c81e6d2ede77951b81aff @technoweenie technoweenie committed Feb 7, 2008
View
@@ -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]
@@ -113,7 +113,7 @@ def format
# 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
@@ -371,6 +371,13 @@ def test_content_type
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

0 comments on commit 8e6638a

Please sign in to comment.