Changeset 7479
- Timestamp:
- 09/15/07 04:18:32 (1 year ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/request.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/mime_responds_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r7478 r7479 1 1 *SVN* 2 3 * Fixed that setting request.format would also affect respond_to blocks [DHH] 2 4 3 5 * Add option to force binary mode on tempfile used for fixture_file_upload. #6380 [Jonathan Viney] trunk/actionpack/lib/action_controller/request.rb
r7438 r7479 12 12 # such as { 'RAILS_ENV' => 'production' }. 13 13 attr_reader :env 14 15 # The requested content type, such as :html or :xml.16 attr_writer :format17 14 18 15 # The HTTP request method as a lowercase symbol, such as :get. … … 90 87 def format 91 88 @format ||= parameters[:format] ? Mime::Type.lookup_by_extension(parameters[:format]) : accepts.first 89 end 90 91 92 # Sets the format by string extension, which can be used to force custom formats that are not controlled by the extension. 93 # Example: 94 # 95 # class ApplicationController < ActionController::Base 96 # before_filter :adjust_format_for_iphone 97 # 98 # private 99 # def adjust_format_for_iphone 100 # request.format = :iphone if request.env["HTTP_USER_AGENT"][/iPhone/] 101 # end 102 # end 103 def format=(extension) 104 parameters[:format] = extension.to_s 105 format 92 106 end 93 107 trunk/actionpack/test/controller/mime_responds_test.rb
r6856 r7479 33 33 type.xml { render :text => "XML" } 34 34 type.all { render :text => "Nothing" } 35 end 36 end 37 38 def forced_xml 39 request.format = :xml 40 41 respond_to do |type| 42 type.html { render :text => "HTML" } 43 type.xml { render :text => "XML" } 35 44 end 36 45 end … … 344 353 end 345 354 355 def test_internally_forced_format 356 get :forced_xml 357 assert_equal "XML", @response.body 358 359 get :forced_xml, :format => "html" 360 assert_equal "XML", @response.body 361 end 362 346 363 def test_extension_synonyms 347 364 get :html_xml_or_rss, :format => "xhtml"