aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/request.rb2
-rw-r--r--actionpack/test/controller/request_test.rb7
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