Upgraded Rails
[monkeycharger.git] / vendor / rails / actionpack / test / controller / custom_handler_test.rb
blob2747a0f3caf972570557cf915d6ced3089c8b3b2
1 require File.dirname(__FILE__) + '/../abstract_unit'
3 class CustomHandler
4   def initialize( view )
5     @view = view
6   end
8   def render( template, local_assigns )
9     [ template,
10       local_assigns,
11       @view ]
12   end
13 end
15 class CustomHandlerTest < Test::Unit::TestCase
16   def setup
17     ActionView::Base.register_template_handler "foo", CustomHandler
18     ActionView::Base.register_template_handler :foo2, CustomHandler
19     @view = ActionView::Base.new
20   end
22   def test_custom_render
23     result = @view.render_template( "foo", "hello <%= one %>", nil, :one => "two" )
24     assert_equal(
25       [ "hello <%= one %>", { :one => "two" }, @view ],
26       result )
27   end
29   def test_custom_render2
30     result = @view.render_template( "foo2", "hello <%= one %>", nil, :one => "two" )
31     assert_equal(
32       [ "hello <%= one %>", { :one => "two" }, @view ],
33       result )
34   end
36   def test_unhandled_extension
37     # uses the ERb handler by default if the extension isn't recognized
38     result = @view.render_template( "bar", "hello <%= one %>", nil, :one => "two" )
39     assert_equal "hello two", result
40   end
41 end