diff options
author | Aaron Patterson <tenderlove@github.com> | 2019-02-19 15:32:50 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-19 15:32:50 -0800 |
commit | f42f1d3155cdb787f90f489d6042ef64be4e6e5f (patch) | |
tree | f2680c6d2dac62bb51cbc2a7c35c7953131d68fa /actionview/test | |
parent | ff6b713f5e729859995f204093ad3f8e08f39ea8 (diff) | |
parent | 3f84a814aa1d934fc0e577ff1d69f0e814b9d1c2 (diff) | |
download | rails-f42f1d3155cdb787f90f489d6042ef64be4e6e5f.tar.gz rails-f42f1d3155cdb787f90f489d6042ef64be4e6e5f.tar.bz2 rails-f42f1d3155cdb787f90f489d6042ef64be4e6e5f.zip |
Merge pull request #35265 from rails/return-rendered-templates
Return rendered template objects from renderers
Diffstat (limited to 'actionview/test')
-rw-r--r-- | actionview/test/actionpack/controller/render_test.rb | 11 | ||||
-rw-r--r-- | actionview/test/template/render_test.rb | 14 |
2 files changed, 19 insertions, 6 deletions
diff --git a/actionview/test/actionpack/controller/render_test.rb b/actionview/test/actionpack/controller/render_test.rb index 727d3fbc1a..52c3c54d96 100644 --- a/actionview/test/actionpack/controller/render_test.rb +++ b/actionview/test/actionpack/controller/render_test.rb @@ -174,6 +174,10 @@ class TestController < ActionController::Base render inline: "<%= controller_name %>" end + def inline_rendered_format_without_format + render inline: "test" + end + # :ported: def render_custom_code render plain: "hello world", status: 404 @@ -659,6 +663,7 @@ class RenderTest < ActionController::TestCase get :hello_world_from_rxml_using_action, to: "test#hello_world_from_rxml_using_action" get :hello_world_from_rxml_using_template, to: "test#hello_world_from_rxml_using_template" get :hello_world_with_layout_false, to: "test#hello_world_with_layout_false" + get :inline_rendered_format_without_format, to: "test#inline_rendered_format_without_format" get :layout_overriding_layout, to: "test#layout_overriding_layout" get :layout_test, to: "test#layout_test" get :layout_test_with_different_layout, to: "test#layout_test_with_different_layout" @@ -1015,6 +1020,12 @@ class RenderTest < ActionController::TestCase assert_equal "<wrapper>\n<html>\n <p>Hello </p>\n<p>This is grand!</p>\n</html>\n</wrapper>\n", @response.body end + def test_rendered_format_without_format + get :inline_rendered_format_without_format + assert_equal "test", @response.body + assert_equal "text/html", @response.content_type + end + def test_partials_list get :partials_list assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index 5068e00c7d..ee8a110b44 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -69,11 +69,6 @@ module RenderTestCases assert_match "<error>No Comment</error>", @view.render(template: "comments/empty", formats: [:xml]) end - def test_rendered_format_without_format - @view.render(inline: "test") - assert_equal :html, @view.lookup_context.rendered_format - end - def test_render_partial_implicitly_use_format_of_the_rendered_template @view.lookup_context.formats = [:json] assert_equal "Hello world", @view.render(template: "test/one", formats: [:html]) @@ -743,10 +738,17 @@ class CachedCollectionViewRenderTest < ActiveSupport::TestCase end teardown do - GC.start I18n.reload! end + test "template body written to cache" do + customer = Customer.new("david", 1) + key = cache_key(customer, "test/_customer") + assert_nil ActionView::PartialRenderer.collection_cache.read(key) + @view.render(partial: "test/customer", collection: [customer], cached: true) + assert_equal "Hello: david", ActionView::PartialRenderer.collection_cache.read(key) + end + test "collection caching does not cache by default" do customer = Customer.new("david", 1) key = cache_key(customer, "test/_customer") |