diff options
Diffstat (limited to 'actionpack/test/abstract')
-rw-r--r-- | actionpack/test/abstract/layouts_test.rb | 61 | ||||
-rw-r--r-- | actionpack/test/abstract/translation_test.rb | 4 |
2 files changed, 52 insertions, 13 deletions
diff --git a/actionpack/test/abstract/layouts_test.rb b/actionpack/test/abstract/layouts_test.rb index 86208899f8..fc25718d9e 100644 --- a/actionpack/test/abstract/layouts_test.rb +++ b/actionpack/test/abstract/layouts_test.rb @@ -57,11 +57,8 @@ module AbstractControllerTests layout "hello_override" end - class WithNilChild < WithString - layout nil - end - class WithStringImpliedChild < WithString + layout nil end class WithChildOfImplied < WithStringImpliedChild @@ -141,6 +138,30 @@ module AbstractControllerTests end end + class WithOnlyConditional < WithStringImpliedChild + layout "overwrite", :only => :show + + def index + render :template => ActionView::Template::Text.new("Hello index!") + end + + def show + render :template => ActionView::Template::Text.new("Hello show!") + end + end + + class WithExceptConditional < WithStringImpliedChild + layout "overwrite", :except => :show + + def index + render :template => ActionView::Template::Text.new("Hello index!") + end + + def show + render :template => ActionView::Template::Text.new("Hello show!") + end + end + class TestBase < ActiveSupport::TestCase test "when no layout is specified, and no default is available, render without a layout" do controller = Blank.new @@ -238,12 +259,6 @@ module AbstractControllerTests assert_equal "With Implied Hello string!", controller.response_body end - test "when a child controller specifies layout nil, do not use the parent layout" do - controller = WithNilChild.new - controller.process(:index) - assert_equal "Hello string!", controller.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 controller = WithChildOfImplied.new @@ -260,6 +275,30 @@ module AbstractControllerTests end end end + + test "when specify an :only option which match current action name" do + controller = WithOnlyConditional.new + controller.process(:show) + assert_equal "Overwrite Hello show!", controller.response_body + end + + test "when specify an :only option which does not match current action name" do + controller = WithOnlyConditional.new + controller.process(:index) + assert_equal "With Implied Hello index!", controller.response_body + end + + test "when specify an :except option which match current action name" do + controller = WithExceptConditional.new + controller.process(:show) + assert_equal "With Implied Hello show!", controller.response_body + end + + test "when specify an :except option which does not match current action name" do + controller = WithExceptConditional.new + controller.process(:index) + assert_equal "Overwrite Hello index!", controller.response_body + end end end -end
\ No newline at end of file +end diff --git a/actionpack/test/abstract/translation_test.rb b/actionpack/test/abstract/translation_test.rb index 8ec50fd57a..0194ee943f 100644 --- a/actionpack/test/abstract/translation_test.rb +++ b/actionpack/test/abstract/translation_test.rb @@ -3,7 +3,7 @@ require 'abstract_unit' # class TranslatingController < ActionController::Base # end -class TranslationControllerTest < Test::Unit::TestCase +class TranslationControllerTest < ActiveSupport::TestCase def setup @controller = ActionController::Base.new end @@ -23,4 +23,4 @@ class TranslationControllerTest < Test::Unit::TestCase def test_action_controller_base_responds_to_l assert_respond_to @controller, :l end -end
\ No newline at end of file +end |