Skip to content

Commit

Permalink
Merge pull request rails#39480 from rails/js_html_fallback
Browse files Browse the repository at this point in the history
Add test for HTML format fallback from JS template
  • Loading branch information
tenderlove committed May 29, 2020
2 parents 801741f + 5888c35 commit 088de51
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions actionview/test/fixtures/test/_js_html_fallback.html.erb
@@ -0,0 +1 @@
<b>Hello from a HTML partial!</b>
1 change: 1 addition & 0 deletions actionview/test/fixtures/test/js_html_fallback.js.erb
@@ -0,0 +1 @@
document.write("<%= j render(partial: "js_html_fallback").chomp.html_safe %>")
5 changes: 5 additions & 0 deletions actionview/test/template/render_test.rb
Expand Up @@ -58,6 +58,11 @@ def test_implicit_format_comes_from_parent_template_cascading
] }, rendered_templates)
end

def test_explicit_js_format_adds_html_fallback
rendered_templates = @controller_view.render(template: "test/js_html_fallback", formats: :js)
assert_equal(%Q(document.write("<b>Hello from a HTML partial!<\\/b>")\n), rendered_templates)
end

def test_render_without_options
e = assert_raises(ArgumentError) { @view.render() }
assert_match(/You invoked render but did not give any of (.+) option\./, e.message)
Expand Down

0 comments on commit 088de51

Please sign in to comment.