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

Ticket #8737: layout_broken_with_only.diff

File layout_broken_with_only.diff, 1.1 kB (added by lifofifo, 2 years ago)

Test case for when inherited layouts break with :only option

  • actionpack/test/controller/layout_test.rb

    old new  
    135135class DefaultLayoutController < LayoutTest 
    136136end 
    137137 
     138class UsesMultipleLayoutController < LayoutTest 
     139  layout 'item', :only => :hello 
     140  def world 
     141    render :template => 'hello' 
     142  end 
     143end 
     144 
    138145class HasOwnLayoutController < LayoutTest 
    139146  layout 'item' 
    140147end 
     
    163170    assert_equal 'layouts/layout_test', @response.layout 
    164171  end 
    165172   
     173  def test_layout_set_when_set_with_only 
     174    @controller = UsesMultipleLayoutController.new 
     175    get :hello 
     176    assert_equal 'layouts/item', @response.layout 
     177  end 
     178   
     179  def test_parent_layout_set_when_only_conditional_layout_used 
     180    @controller = UsesMultipleLayoutController.new 
     181    get :world 
     182    assert_equal 'layouts/layout_test', @response.layout 
     183  end 
     184   
    166185  def test_layout_set_when_set_in_controller 
    167186    @controller = HasOwnLayoutController.new 
    168187    get :hello