diff options
Diffstat (limited to 'actionpack/test')
6 files changed, 20 insertions, 5 deletions
diff --git a/actionpack/test/fixtures/plain_text.raw b/actionpack/test/fixtures/plain_text.raw new file mode 100644 index 0000000000..b13985337f --- /dev/null +++ b/actionpack/test/fixtures/plain_text.raw @@ -0,0 +1 @@ +<%= hello_world %> diff --git a/actionpack/test/fixtures/plain_text_with_characters.raw b/actionpack/test/fixtures/plain_text_with_characters.raw new file mode 100644 index 0000000000..1e86e44fb4 --- /dev/null +++ b/actionpack/test/fixtures/plain_text_with_characters.raw @@ -0,0 +1 @@ +Here are some characters: !@#$%^&*()-="'}{` diff --git a/actionpack/test/template/render_test.rb b/actionpack/test/template/render_test.rb index e7f5f100bf..88ed8664c2 100644 --- a/actionpack/test/template/render_test.rb +++ b/actionpack/test/template/render_test.rb @@ -79,6 +79,14 @@ module RenderTestCases assert_equal "<h1>No Comment</h1>\n", @view.render(:template => "comments/empty", :handlers => [:builder]) end + def test_render_raw_template_with_handlers + assert_equal "<%= hello_world %>\n", @view.render(:template => "plain_text") + end + + def test_render_raw_template_with_quotes + assert_equal %q;Here are some characters: !@#$%^&*()-="'}{`; + "\n", @view.render(:template => "plain_text_with_characters") + end + def test_render_file_with_localization_on_context_level old_locale, @view.locale = @view.locale, :da assert_equal "Hey verden", @view.render(:file => "test/hello_world") diff --git a/actionpack/test/template/template_test.rb b/actionpack/test/template/template_test.rb index 8c57ada587..322bea3fb0 100644 --- a/actionpack/test/template/template_test.rb +++ b/actionpack/test/template/template_test.rb @@ -48,7 +48,7 @@ class TestERBTemplate < ActiveSupport::TestCase end def new_template(body = "<%= hello %>", details = {}) - ActionView::Template.new(body, "hello template", ERBHandler, {:virtual_path => "hello"}.merge!(details)) + ActionView::Template.new(body, "hello template", details.fetch(:handler) { ERBHandler }, {:virtual_path => "hello"}.merge!(details)) end def render(locals = {}) @@ -64,6 +64,11 @@ class TestERBTemplate < ActiveSupport::TestCase assert_equal "Hello", render end + def test_raw_template + @template = new_template("<%= hello %>", :handler => ActionView::Template::Handlers::Raw.new) + assert_equal "<%= hello %>", render + end + def test_template_loses_its_source_after_rendering @template = new_template render diff --git a/actionpack/test/template/testing/fixture_resolver_test.rb b/actionpack/test/template/testing/fixture_resolver_test.rb index de83540468..9649f349cb 100644 --- a/actionpack/test/template/testing/fixture_resolver_test.rb +++ b/actionpack/test/template/testing/fixture_resolver_test.rb @@ -8,8 +8,8 @@ class FixtureResolverTest < ActiveSupport::TestCase end def test_should_return_template_for_declared_path - resolver = ActionView::FixtureResolver.new("arbitrary/path" => "this text") - templates = resolver.find_all("path", "arbitrary", false, {:locale => [], :formats => [:html], :handlers => []}) + resolver = ActionView::FixtureResolver.new("arbitrary/path.erb" => "this text") + templates = resolver.find_all("path", "arbitrary", false, {:locale => [], :formats => [:html], :handlers => [:erb]}) assert_equal 1, templates.size, "expected one template" assert_equal "this text", templates.first.source assert_equal "arbitrary/path", templates.first.virtual_path diff --git a/actionpack/test/template/testing/null_resolver_test.rb b/actionpack/test/template/testing/null_resolver_test.rb index e142506e6a..535ad3ab14 100644 --- a/actionpack/test/template/testing/null_resolver_test.rb +++ b/actionpack/test/template/testing/null_resolver_test.rb @@ -3,10 +3,10 @@ require 'abstract_unit' class NullResolverTest < ActiveSupport::TestCase def test_should_return_template_for_any_path resolver = ActionView::NullResolver.new() - templates = resolver.find_all("path", "arbitrary", false, {:locale => [], :formats => [:html], :handlers => []}) + templates = resolver.find_all("path.erb", "arbitrary", false, {:locale => [], :formats => [:html], :handlers => []}) assert_equal 1, templates.size, "expected one template" assert_equal "Template generated by Null Resolver", templates.first.source - assert_equal "arbitrary/path", templates.first.virtual_path + assert_equal "arbitrary/path.erb", templates.first.virtual_path assert_equal [:html], templates.first.formats end end |