aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/new_base/render_layout_test.rb
blob: 7f627f86ec46c6a5ecebaec29f7ee7c788dc0411 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")

module ControllerLayouts
  class ImplicitController < ::ApplicationController
    
    self.view_paths = [ActionView::Template::FixturePath.new(
      "layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI",
      "layouts/override.html.erb"    => "Override! <%= yield %>",
      "basic.html.erb"               => "Hello world!",
      "controller_layouts/implicit/layout_false.html.erb" => "hai(layout_false.html.erb)"
    )]
    
    def index
      render :template => "basic"
    end
    
    def override
      render :template => "basic", :layout => "override"
    end
    
    def layout_false
      render :layout => false
    end
    
    
    
    def builder_override
      
    end
  end
  
  class TestImplicitLayout < SimpleRouteCase
    describe "rendering a normal template, but using the implicit layout"
    
    get "/controller_layouts/implicit/index"
    assert_body   "OMG Hello world! KTHXBAI"
    assert_status 200
  end
  
  class ImplicitNameController < ::ApplicationController
    
    self.view_paths = [ActionView::Template::FixturePath.new(
      "layouts/controller_layouts/implicit_name.html.erb" => "OMGIMPLICIT <%= yield %> KTHXBAI",
      "basic.html.erb" => "Hello world!"
    )]
        
    def index
      render :template => "basic"
    end
  end
  
  class TestImplicitNamedLayout < SimpleRouteCase
    describe "rendering a normal template, but using an implicit NAMED layout"
    
    get "/controller_layouts/implicit_name/index"
    assert_body   "OMGIMPLICIT Hello world! KTHXBAI"
    assert_status 200
  end
  
  class TestOverridingImplicitLayout < SimpleRouteCase
    describe "overriding an implicit layout with render :layout option"
    
    get "/controller_layouts/implicit/override"
    assert_body "Override! Hello world!"
  end
  
  class TestLayoutOptions < SimpleRouteCase
    testing ControllerLayouts::ImplicitController
    
    test "rendering with :layout => false leaves out the implicit layout" do
      get :layout_false
      assert_response "hai(layout_false.html.erb)"
    end
  end
end