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

Changeset 5928

Show
Ignore:
Timestamp:
01/14/07 14:44:03 (2 years ago)
Author:
bitsweat
Message:

Merge [5909], [5927] from trunk. References #6742, #7026.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-pre-release/actionpack/CHANGELOG

    r5906 r5928  
    11*SVN* 
     2 
     3* Allow exempt_from_layout :rhtml.  #6742, #7026 [dcmanges, Squeegy] 
    24 
    35* Fix parsing of array[] CGI parameters so extra empty values aren't included.  #6252 [Nicholas Seckar, aiwilliams, brentrowland] 
  • branches/1-2-pre-release/actionpack/lib/action_controller/base.rb

    r5699 r5928  
    408408      # Don't render layouts for templates with the given extensions. 
    409409      def exempt_from_layout(*extensions) 
    410         regexps = extensions.collect do |extension| 
    411           extension.is_a?(Regexp) ? extension : /\.#{Regexp.escape(extension.to_s)}$/ 
    412         end 
    413         @@exempt_from_layout.merge regexps 
     410        @@exempt_from_layout.merge extensions.collect { |extension| 
     411          if extension.is_a?(Regexp) 
     412            extension 
     413          else 
     414            /\.#{Regexp.escape(extension.to_s)}$/ 
     415          end 
     416        } 
    414417      end 
    415418    end 
     
    11911194 
    11921195      def template_exempt_from_layout?(template_name = default_template_name) 
    1193         @@exempt_from_layout.any? { |ext| template_name =~ ext } or 
    1194           @template.pick_template_extension(template_name) == :rjs 
    1195       rescue 
    1196         false 
     1196        extension = @template.pick_template_extension(template_name) rescue nil 
     1197        name_with_extension = !template_name.include?('.') && extension ? "#{template_name}.#{extension}" : template_name 
     1198        extension == :rjs || @@exempt_from_layout.any? { |ext| name_with_extension =~ ext } 
    11971199      end 
    11981200 
  • branches/1-2-pre-release/actionpack/test/controller/layout_test.rb

    r5126 r5928  
    7676  def setup 
    7777    @controller = LayoutTest.new 
     78    @request    = ActionController::TestRequest.new 
     79    @response   = ActionController::TestResponse.new 
    7880  end 
    7981 
     
    103105    ActionController::Base.exempt_from_layout /\.rdoc/ 
    104106    assert @controller.send(:template_exempt_from_layout?, 'test.rdoc') 
     107  end 
     108 
     109  def test_rhtml_exempt_from_layout_status_should_prevent_layout_render 
     110    ActionController::Base.exempt_from_layout :rhtml 
     111    assert @controller.send(:template_exempt_from_layout?, 'test.rhtml') 
     112 
     113    get :hello 
     114    assert_equal 'hello.rhtml', @response.body 
     115    ActionController::Base.exempt_from_layout.delete(/\.rhtml$/) 
    105116  end 
    106117end