2009-04-07 20:57:20 -04:00
|
|
|
require File.join(File.expand_path(File.dirname(__FILE__)), "test_helper")
|
|
|
|
|
|
|
|
module ControllerLayouts
|
|
|
|
class ImplicitController < ::ApplicationController
|
|
|
|
|
2009-04-27 21:21:26 -04:00
|
|
|
self.view_paths = [ActionView::Template::FixturePath.new(
|
2009-04-07 20:57:20 -04:00
|
|
|
"layouts/application.html.erb" => "OMG <%= yield %> KTHXBAI",
|
2009-05-01 14:40:32 -04:00
|
|
|
"layouts/override.html.erb" => "Override! <%= yield %>",
|
|
|
|
"basic.html.erb" => "Hello world!"
|
2009-04-07 20:57:20 -04:00
|
|
|
)]
|
|
|
|
|
|
|
|
def index
|
|
|
|
render :template => "basic"
|
|
|
|
end
|
2009-05-01 14:40:32 -04:00
|
|
|
|
|
|
|
def override
|
|
|
|
render :template => "basic", :layout => "override"
|
|
|
|
end
|
|
|
|
|
|
|
|
def builder_override
|
|
|
|
|
|
|
|
end
|
2009-04-07 20:57:20 -04:00
|
|
|
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
|
|
|
|
|
2009-04-27 21:21:26 -04:00
|
|
|
self.view_paths = [ActionView::Template::FixturePath.new(
|
2009-04-07 20:57:20 -04:00
|
|
|
"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
|
|
|
|
|
2009-05-01 14:40:32 -04:00
|
|
|
class TestOverridingImplicitLayout < SimpleRouteCase
|
|
|
|
describe "overriding an implicit layout with render :layout option"
|
|
|
|
|
|
|
|
get "/controller_layouts/implicit/override"
|
|
|
|
assert_body "Override! Hello world!"
|
|
|
|
end
|
2009-04-07 20:57:20 -04:00
|
|
|
end
|