diff options
Diffstat (limited to 'actionpack/test/abstract_controller/layouts_test.rb')
-rw-r--r-- | actionpack/test/abstract_controller/layouts_test.rb | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/actionpack/test/abstract_controller/layouts_test.rb b/actionpack/test/abstract_controller/layouts_test.rb index d3440c3de0..b28df7743f 100644 --- a/actionpack/test/abstract_controller/layouts_test.rb +++ b/actionpack/test/abstract_controller/layouts_test.rb @@ -9,7 +9,7 @@ module AbstractControllerTests include AbstractController::Renderer include AbstractController::Layouts - self.view_paths = [ActionView::Template::FixturePath.new( + self.view_paths = [ActionView::FixtureResolver.new( "layouts/hello.erb" => "With String <%= yield %>", "layouts/hello_override.erb" => "With Override <%= yield %>", "layouts/abstract_controller_tests/layouts/with_string_implied_child.erb" => @@ -25,7 +25,7 @@ module AbstractControllerTests def controller_path() self.class.controller_path end def render_to_body(options) - options[:_layout] = _default_layout + options[:_layout] = _default_layout({}) super end end @@ -141,91 +141,82 @@ module AbstractControllerTests end end - # TODO Move to bootloader - AbstractController::Base.subclasses.each do |klass| - klass = klass.constantize - next unless klass < AbstractController::Layouts - klass.class_eval do - _write_layout_method - end - end - class TestBase < ActiveSupport::TestCase test "when no layout is specified, and no default is available, render without a layout" do - result = Blank.process(:index) + result = Blank.new.process(:index) assert_equal "Hello blank!", result.response_body end test "when layout is specified as a string, render with that layout" do - result = WithString.process(:index) + result = WithString.new.process(:index) assert_equal "With String Hello string!", result.response_body end test "when layout is specified as a string, but the layout is missing, raise an exception" do - assert_raises(ActionView::MissingTemplate) { WithMissingLayout.process(:index) } + assert_raises(ActionView::MissingTemplate) { WithMissingLayout.new.process(:index) } end test "when layout is specified as false, do not use a layout" do - result = WithFalseLayout.process(:index) + result = WithFalseLayout.new.process(:index) assert_equal "Hello false!", result.response_body end test "when layout is specified as nil, do not use a layout" do - result = WithNilLayout.process(:index) + result = WithNilLayout.new.process(:index) assert_equal "Hello nil!", result.response_body end test "when layout is specified as a symbol, call the requested method and use the layout returned" do - result = WithSymbol.process(:index) + result = WithSymbol.new.process(:index) assert_equal "OMGHI2U Hello symbol!", result.response_body end test "when layout is specified as a symbol and the method returns nil, don't use a layout" do - result = WithSymbolReturningNil.process(:index) + result = WithSymbolReturningNil.new.process(:index) assert_equal "Hello nilz!", result.response_body end test "when the layout is specified as a symbol and the method doesn't exist, raise an exception" do - assert_raises(NoMethodError, /:nilz/) { WithSymbolAndNoMethod.process(:index) } + assert_raises(NoMethodError, /:nilz/) { WithSymbolAndNoMethod.new.process(:index) } end test "when the layout is specified as a symbol and the method returns something besides a string/false/nil, raise an exception" do - assert_raises(ArgumentError) { WithSymbolReturningObj.process(:index) } + assert_raises(ArgumentError) { WithSymbolReturningObj.new.process(:index) } end test "when a child controller does not have a layout, use the parent controller layout" do - result = WithStringChild.process(:index) + result = WithStringChild.new.process(:index) assert_equal "With String Hello string!", result.response_body end test "when a child controller has specified a layout, use that layout and not the parent controller layout" do - result = WithStringOverriddenChild.process(:index) + result = WithStringOverriddenChild.new.process(:index) assert_equal "With Override Hello string!", result.response_body end test "when a child controller has an implied layout, use that layout and not the parent controller layout" do - result = WithStringImpliedChild.process(:index) + result = WithStringImpliedChild.new.process(:index) assert_equal "With Implied Hello string!", result.response_body end test "when a child controller specifies layout nil, do not use the parent layout" do - result = WithNilChild.process(:index) + result = WithNilChild.new.process(:index) assert_equal "Hello string!", result.response_body end test "when a grandchild has no layout specified, the child has an implied layout, and the " \ "parent has specified a layout, use the child controller layout" do - result = WithChildOfImplied.process(:index) + result = WithChildOfImplied.new.process(:index) assert_equal "With Implied Hello string!", result.response_body end test "raises an exception when specifying layout true" do assert_raises ArgumentError do - Object.class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1 + Object.class_eval do class ::BadOmgFailLolLayout < AbstractControllerTests::Layouts::Base layout true end - RUBY_EVAL + end end end end |