From 4fb75392aa12228764758dfda95f02f83b8ce3fe Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 30 Aug 2008 21:42:53 +0100 Subject: Add test to make sure RJS block inside controller is executed in view context --- actionpack/test/controller/render_test.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'actionpack/test/controller/render_test.rb') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index e383fda384..8d15aa2da4 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -371,6 +371,12 @@ class TestController < ActionController::Base end end + def update_page_with_view_method + render :update do |page| + page.replace_html 'person', pluralize(2, 'person') + end + end + def action_talk_to_layout # Action template sets variable that's picked up by layout end @@ -1022,6 +1028,13 @@ class RenderTest < Test::Unit::TestCase assert_match /\$37/, @response.body end + def test_update_page_with_view_method + get :update_page_with_view_method + assert_template nil + assert_equal 'text/javascript; charset=utf-8', @response.headers['type'] + assert_match /2 people/, @response.body + end + def test_yield_content_for assert_not_deprecated { get :yield_content_for } assert_equal "Putting stuff in the title!\n\nGreat stuff!\n", @response.body -- cgit v1.2.3 From 56c2b02f592aa7c127346f2c68ac45236c27702e Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sun, 31 Aug 2008 16:29:21 +0100 Subject: Fix AM tests and add tests for rendering logging --- actionpack/test/controller/render_test.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'actionpack/test/controller/render_test.rb') diff --git a/actionpack/test/controller/render_test.rb b/actionpack/test/controller/render_test.rb index 8d15aa2da4..c4a2bf3db3 100644 --- a/actionpack/test/controller/render_test.rb +++ b/actionpack/test/controller/render_test.rb @@ -8,6 +8,18 @@ module Fun end end +class MockLogger + attr_reader :logged + + def initialize + @logged = [] + end + + def method_missing(method, *args) + @logged << args.first + end +end + class TestController < ActionController::Base class LabellingFormBuilder < ActionView::Helpers::FormBuilder end @@ -1385,3 +1397,21 @@ class LastModifiedRenderTest < Test::Unit::TestCase assert_equal @last_modified, @response.headers['Last-Modified'] end end + +class RenderingLoggingTest < Test::Unit::TestCase + def setup + @request = ActionController::TestRequest.new + @response = ActionController::TestResponse.new + @controller = TestController.new + + @request.host = "www.nextangle.com" + end + + def test_logger_prints_layout_and_template_rendering_info + @controller.logger = MockLogger.new + get :layout_test + logged = @controller.logger.logged.find_all {|l| l =~ /render/i } + assert_equal "Rendering template within layouts/standard", logged[0] + assert_equal "Rendering test/hello_world", logged[1] + end +end -- cgit v1.2.3