From 91125f9927ffbe1a16494910ae0e8228a4400439 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Sun, 2 May 2010 09:20:17 -0500 Subject: move FixtureResolver to a file that is accessible outside Rails' own tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [#4522 state:resolved] Signed-off-by: José Valim --- actionpack/test/controller/layout_test.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/layout_test.rb b/actionpack/test/controller/layout_test.rb index 48be7571ea..165c61ffad 100644 --- a/actionpack/test/controller/layout_test.rb +++ b/actionpack/test/controller/layout_test.rb @@ -10,8 +10,6 @@ ActionView::Template::register_template_handler :mab, ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/layout_tests/' ] -require "fixture_template" - class LayoutTest < ActionController::Base def self.controller_path; 'views' end def self._implied_layout_name; to_s.underscore.gsub(/_controller$/, '') ; end -- cgit v1.2.3 From 849ab9294244ac94f9ce4621c8cd325a2992a382 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Thu, 29 Apr 2010 08:18:47 -0500 Subject: Eliminate false positives when passing symbols to assert_template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../test/controller/action_pack_assertions_test.rb | 29 +++++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 1741b58f72..eae2641dc0 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -349,21 +349,43 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase assert_template :partial => '_partial' end - def test_assert_template_with_nil + def test_assert_template_with_nil_passes_when_no_template_rendered get :nothing assert_template nil end - def test_assert_template_with_string + def test_assert_template_with_nil_fails_when_template_rendered + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template nil + end + end + + def test_assert_template_passes_with_correct_string get :hello_world assert_template 'hello_world' + assert_template 'test/hello_world' end - def test_assert_template_with_symbol + def test_assert_template_passes_with_correct_symbol get :hello_world assert_template :hello_world end + def test_assert_template_fails_with_incorrect_string + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template 'hello_planet' + end + end + + def test_assert_template_fails_with_incorrect_symbol + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template :hello_planet + end + end + # check if we were rendered by a file-based template? def test_rendered_action process :nothing @@ -387,7 +409,6 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase assert_nil @response.redirect_url end - # check server errors def test_server_error_response_code process :response500 -- cgit v1.2.3 From b3dcbedc67f49ef64f33570f3e24ac00a47c0181 Mon Sep 17 00:00:00 2001 From: David Chelimsky Date: Thu, 29 Apr 2010 09:29:35 -0500 Subject: move assert_template tests to their own test case [#4501 state:resolved] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: José Valim --- .../test/controller/action_pack_assertions_test.rb | 87 ++++++++++++---------- 1 file changed, 46 insertions(+), 41 deletions(-) (limited to 'actionpack/test/controller') diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index eae2641dc0..765e111226 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -344,47 +344,6 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end end - def test_assert_template_with_partial - get :partial - assert_template :partial => '_partial' - end - - def test_assert_template_with_nil_passes_when_no_template_rendered - get :nothing - assert_template nil - end - - def test_assert_template_with_nil_fails_when_template_rendered - get :hello_world - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_template nil - end - end - - def test_assert_template_passes_with_correct_string - get :hello_world - assert_template 'hello_world' - assert_template 'test/hello_world' - end - - def test_assert_template_passes_with_correct_symbol - get :hello_world - assert_template :hello_world - end - - def test_assert_template_fails_with_incorrect_string - get :hello_world - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_template 'hello_planet' - end - end - - def test_assert_template_fails_with_incorrect_symbol - get :hello_world - assert_raise(ActiveSupport::TestCase::Assertion) do - assert_template :hello_planet - end - end # check if we were rendered by a file-based template? def test_rendered_action @@ -559,6 +518,52 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase end end +class AssertTemplateTest < ActionController::TestCase + tests ActionPackAssertionsController + + def test_with_partial + get :partial + assert_template :partial => '_partial' + end + + def test_with_nil_passes_when_no_template_rendered + get :nothing + assert_template nil + end + + def test_with_nil_fails_when_template_rendered + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template nil + end + end + + def test_passes_with_correct_string + get :hello_world + assert_template 'hello_world' + assert_template 'test/hello_world' + end + + def test_passes_with_correct_symbol + get :hello_world + assert_template :hello_world + end + + def test_fails_with_incorrect_string + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template 'hello_planet' + end + end + + def test_fails_with_incorrect_symbol + get :hello_world + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template :hello_planet + end + end +end + class ActionPackHeaderTest < ActionController::TestCase tests ActionPackAssertionsController -- cgit v1.2.3