2005-02-19 17:22:37 +00:00
|
|
|
require File.dirname(__FILE__) + '/../abstract_unit'
|
|
|
|
|
|
|
|
class CustomHandler
|
|
|
|
def initialize( view )
|
|
|
|
@view = view
|
|
|
|
end
|
|
|
|
|
|
|
|
def render( template, local_assigns )
|
|
|
|
[ template,
|
|
|
|
local_assigns,
|
|
|
|
@view ]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class CustomHandlerTest < Test::Unit::TestCase
|
|
|
|
def setup
|
|
|
|
ActionView::Base.register_template_handler "foo", CustomHandler
|
|
|
|
@view = ActionView::Base.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_custom_render
|
2005-09-27 16:45:39 +00:00
|
|
|
result = @view.render_template( "foo", "hello <%= one %>", nil, :one => "two" )
|
2005-02-19 17:22:37 +00:00
|
|
|
assert_equal(
|
2005-09-27 16:45:39 +00:00
|
|
|
[ "hello <%= one %>", { :one => "two" }, @view ],
|
2005-02-19 17:22:37 +00:00
|
|
|
result )
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_unhandled_extension
|
|
|
|
# uses the ERb handler by default if the extension isn't recognized
|
2005-09-27 16:45:39 +00:00
|
|
|
result = @view.render_template( "bar", "hello <%= one %>", nil, :one => "two" )
|
2005-02-19 17:22:37 +00:00
|
|
|
assert_equal "hello two", result
|
|
|
|
end
|
|
|
|
end
|