From 2525c2aa163ce632c07ff1802f52c7637d306f11 Mon Sep 17 00:00:00 2001 From: Jeff Dean Date: Sat, 4 Apr 2009 01:21:02 -0400 Subject: [PATCH] Added failing test for custom-template-renderer discovery --- actionpack/test/controller/custom_template_test.rb | 34 ++++++++++++++++++++ .../third_party_template_library/index.mab | 1 + 2 files changed, 35 insertions(+), 0 deletions(-) create mode 100644 actionpack/test/controller/custom_template_test.rb create mode 100644 actionpack/test/fixtures/custom_templates/third_party_template_library/index.mab diff --git a/actionpack/test/controller/custom_template_test.rb b/actionpack/test/controller/custom_template_test.rb new file mode 100644 index 0000000..2d53302 --- /dev/null +++ b/actionpack/test/controller/custom_template_test.rb @@ -0,0 +1,34 @@ +require 'abstract_unit' + +# The view_paths array must be set on Base and not LayoutTest so that LayoutTest's inherited +# method has access to the view_paths array when looking for a layout to automatically assign. +old_load_paths = ActionController::Base.view_paths + +ActionView::Template::register_template_handler :mab, + lambda { |template| template.source.inspect } + +ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/custom_templates/' ] + +class TemplateTest < ActionController::Base + def self.controller_path; 'views' end + self.view_paths = ActionController::Base.view_paths.dup +end + +# Restore view_paths to previous value +ActionController::Base.view_paths = old_load_paths + +class ThirdPartyTemplateLibraryController < TemplateTest +end + +class ThirdPartyTemplateAutoDiscoveryTest < ActionController::TestCase + def setup + @request.host = "www.nextangle.com" + end + + def test_third_party_template_library_auto_discovers_view + @controller = ThirdPartyTemplateLibraryController.new + get :index + assert_response :success + assert_equal 'Mab', @response.body + end +end diff --git a/actionpack/test/fixtures/custom_templates/third_party_template_library/index.mab b/actionpack/test/fixtures/custom_templates/third_party_template_library/index.mab new file mode 100644 index 0000000..018abfb --- /dev/null +++ b/actionpack/test/fixtures/custom_templates/third_party_template_library/index.mab @@ -0,0 +1 @@ +Mab \ No newline at end of file -- 1.6.0.2