Sha256: 23844894009d2fa29e347fb0df60a27216ab2164b2aaf4db1916e90ee2a3ed9d

Contents?: true

Size: 1.08 KB

Versions: 97

Compression:

Stored size: 1.08 KB

Contents

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
    ActionView::Base.register_template_handler :foo2, CustomHandler
    @view = ActionView::Base.new
  end

  def test_custom_render
    result = @view.render_template( "foo", "hello <%= one %>", nil, :one => "two" )
    assert_equal(
      [ "hello <%= one %>", { :one => "two" }, @view ],
      result )
  end

  def test_custom_render2
    result = @view.render_template( "foo2", "hello <%= one %>", nil, :one => "two" )
    assert_equal(
      [ "hello <%= one %>", { :one => "two" }, @view ],
      result )
  end

  def test_unhandled_extension
    # uses the ERb handler by default if the extension isn't recognized
    result = @view.render_template( "bar", "hello <%= one %>", nil, :one => "two" )
    assert_equal "hello two", result
  end
end

Version data entries

97 entries across 97 versions & 6 rubygems

Version Path
jstorimer-deep-test-2.0.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-1.4.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-1.3.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-1.2.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-1.1.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-1.0.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-0.2.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
jstorimer-deep-test-0.1.0 sample_rails_project/vendor/rails/actionpack/test/controller/custom_handler_test.rb
actionpack-1.12.1 test/controller/custom_handler_test.rb
actionpack-1.12.0 test/controller/custom_handler_test.rb
actionpack-1.12.2 test/controller/custom_handler_test.rb
actionpack-1.12.4 test/controller/custom_handler_test.rb
actionpack-1.12.3 test/controller/custom_handler_test.rb
actionpack-1.12.5 test/controller/custom_handler_test.rb
actionpack-1.13.0 test/controller/custom_handler_test.rb
actionpack-1.13.3 test/controller/custom_handler_test.rb
actionpack-1.13.4 test/controller/custom_handler_test.rb
actionpack-1.13.6 test/controller/custom_handler_test.rb
actionpack-1.13.2 test/controller/custom_handler_test.rb
actionpack-1.13.1 test/controller/custom_handler_test.rb