diff options
author | Rick Olson <technoweenie@gmail.com> | 2008-02-07 16:46:50 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2008-02-07 16:46:50 +0000 |
commit | 8e6638afa4b9fe7a361c81e6d2ede77951b81aff (patch) | |
tree | 2214ef62e23185938434c226ce6da2185222b830 | |
parent | 689e27567e2a248e262945c52266340d7385aeed (diff) | |
download | rails-8e6638afa4b9fe7a361c81e6d2ede77951b81aff.tar.gz rails-8e6638afa4b9fe7a361c81e6d2ede77951b81aff.tar.bz2 rails-8e6638afa4b9fe7a361c81e6d2ede77951b81aff.zip |
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
-rw-r--r-- | actionpack/CHANGELOG | 2 | ||||
-rwxr-xr-x | actionpack/lib/action_controller/request.rb | 2 | ||||
-rw-r--r-- | actionpack/test/controller/request_test.rb | 7 |
3 files changed, 10 insertions, 1 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index a3b0d6cfb7..7f4256d603 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -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] diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index e3892037d8..df8dbdc789 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -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 diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 520358f739..68d6afb426 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -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 |