diff options
author | Pratik Naik <pratiknaik@gmail.com> | 2009-08-31 22:11:50 +0100 |
---|---|---|
committer | Pratik Naik <pratiknaik@gmail.com> | 2009-08-31 22:11:50 +0100 |
commit | bae00bb1cc392e1cf408369809b9cf85468bef42 (patch) | |
tree | 17103af6eeb5de96c72beda1debce28950cc7fea /actionpack/test/abstract_controller/abstract_controller_test.rb | |
parent | 93c76b2fb08668bc4b8364cc8051476e6d1d15ba (diff) | |
parent | ffd2cf167040b60c26d97c01598560c87bd4b2d3 (diff) | |
download | rails-bae00bb1cc392e1cf408369809b9cf85468bef42.tar.gz rails-bae00bb1cc392e1cf408369809b9cf85468bef42.tar.bz2 rails-bae00bb1cc392e1cf408369809b9cf85468bef42.zip |
Merge commit 'mainstream/master'
Diffstat (limited to 'actionpack/test/abstract_controller/abstract_controller_test.rb')
-rw-r--r-- | actionpack/test/abstract_controller/abstract_controller_test.rb | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/actionpack/test/abstract_controller/abstract_controller_test.rb b/actionpack/test/abstract_controller/abstract_controller_test.rb index 9438a4dfc9..7991436703 100644 --- a/actionpack/test/abstract_controller/abstract_controller_test.rb +++ b/actionpack/test/abstract_controller/abstract_controller_test.rb @@ -19,8 +19,9 @@ module AbstractController class TestBasic < ActiveSupport::TestCase test "dispatching works" do - result = Me.new.process(:index) - assert_equal "Hello world", result.response_body + controller = Me.new + controller.process(:index) + assert_equal "Hello world", controller.response_body end end @@ -67,29 +68,33 @@ module AbstractController end class TestRenderingController < ActiveSupport::TestCase + def setup + @controller = Me2.new + end + test "rendering templates works" do - result = Me2.new.process(:index) - assert_equal "Hello from index.erb", result.response_body + @controller.process(:index) + assert_equal "Hello from index.erb", @controller.response_body end test "rendering passes ivars to the view" do - result = Me2.new.process(:action_with_ivars) - assert_equal "Hello from index_with_ivars.erb", result.response_body + @controller.process(:action_with_ivars) + assert_equal "Hello from index_with_ivars.erb", @controller.response_body end test "rendering with no template name" do - result = Me2.new.process(:naked_render) - assert_equal "Hello from naked_render.erb", result.response_body + @controller.process(:naked_render) + assert_equal "Hello from naked_render.erb", @controller.response_body end test "rendering to a rack body" do - result = Me2.new.process(:rendering_to_body) - assert_equal "Hello from naked_render.erb", result.response_body + @controller.process(:rendering_to_body) + assert_equal "Hello from naked_render.erb", @controller.response_body end test "rendering to a string" do - result = Me2.new.process(:rendering_to_string) - assert_equal "Hello from naked_render.erb", result.response_body + @controller.process(:rendering_to_string) + assert_equal "Hello from naked_render.erb", @controller.response_body end end @@ -119,14 +124,18 @@ module AbstractController end class TestPrefixedViews < ActiveSupport::TestCase + def setup + @controller = Me3.new + end + test "templates are located inside their 'prefix' folder" do - result = Me3.new.process(:index) - assert_equal "Hello from me3/index.erb", result.response_body + @controller.process(:index) + assert_equal "Hello from me3/index.erb", @controller.response_body end test "templates included their format" do - result = Me3.new.process(:formatted) - assert_equal "Hello from me3/formatted.html.erb", result.response_body + @controller.process(:formatted) + assert_equal "Hello from me3/formatted.html.erb", @controller.response_body end end @@ -168,8 +177,9 @@ module AbstractController class TestLayouts < ActiveSupport::TestCase test "layouts are included" do - result = Me4.new.process(:index) - assert_equal "Me4 Enter : Hello from me4/index.erb : Exit", result.response_body + controller = Me4.new + result = controller.process(:index) + assert_equal "Me4 Enter : Hello from me4/index.erb : Exit", controller.response_body end end @@ -203,10 +213,11 @@ module AbstractController end class TestRespondToAction < ActiveSupport::TestCase - + def assert_dispatch(klass, body = "success", action = :index) - response = klass.new.process(action).response_body - assert_equal body, response + controller = klass.new + controller.process(action) + assert_equal body, controller.response_body end test "an arbitrary method is available as an action by default" do |