Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7629

Show
Ignore:
Timestamp:
09/25/07 14:57:15 (1 year ago)
Author:
david
Message:

Added failing tests for iphone

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/layout.rb

    r7514 r7629  
    235235    protected 
    236236      def render_with_a_layout(options = nil, &block) #:nodoc: 
    237         if template_with_options = options.is_a?(Hash) 
    238           response.template.template_format = options[:content_type].to_sym if options[:content_type] 
    239         end 
    240  
     237        template_with_options = options.is_a?(Hash) 
     238        set_template_format(options) 
     239         
    241240        if apply_layout?(template_with_options, options) && (layout = pick_layout(template_with_options, options)) 
    242241          assert_existence_of_template_file(layout) 
     
    308307        end 
    309308      end 
     309       
     310      def set_template_format(options) 
     311        if options.is_a?(Hash) && options[:content_type] 
     312          response.template.template_format = options[:content_type].to_sym  
     313        elsif params[:format] 
     314          response.template.template_format = Mime::Type.lookup(Mime::Type.lookup_by_extension(params[:format]).to_s).to_sym 
     315        end 
     316      end 
    310317  end 
    311318end 
  • trunk/actionpack/test/controller/mime_responds_test.rb

    r7625 r7629  
    117117  def iphone_with_html_response_type  
    118118    Mime::Type.register_alias("text/html", :iphone) 
    119  
     119    request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone" 
     120     
    120121    respond_to do |type| 
    121122      type.html   { @type = "Firefox" } 
     
    400401    get :iphone_with_html_response_type, :format => "iphone" 
    401402    assert_equal "text/html", @response.content_type 
    402     assert_equal "<html>Hello future from iPhone!</html>", @response.body 
     403    assert_equal "<html>Hello iPhone future from iPhone!</html>", @response.body 
    403404  end  
    404405