diff options
author | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:36:34 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2016-08-06 19:36:34 +0200 |
commit | 63fff600accb41b56a3e6ac403d9b1732de3086d (patch) | |
tree | eabc84f16214eade7d44386de14a23415a9c3e3d /actionview/test/template/tag_helper_test.rb | |
parent | 5b6eb1d58b48fada298215b2cccda89f993890c3 (diff) | |
download | rails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.gz rails-63fff600accb41b56a3e6ac403d9b1732de3086d.tar.bz2 rails-63fff600accb41b56a3e6ac403d9b1732de3086d.zip |
modernizes hash syntax in actionview
Diffstat (limited to 'actionview/test/template/tag_helper_test.rb')
-rw-r--r-- | actionview/test/template/tag_helper_test.rb | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/actionview/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb index 0c8bfd03d7..5b67b657be 100644 --- a/actionview/test/template/tag_helper_test.rb +++ b/actionview/test/template/tag_helper_test.rb @@ -7,7 +7,7 @@ class TagHelperTest < ActionView::TestCase def test_tag assert_equal "<br />", tag("br") - assert_equal "<br clear=\"left\" />", tag(:br, :clear => "left") + assert_equal "<br clear=\"left\" />", tag(:br, clear: "left") assert_equal "<br>", tag("br", nil, true) end @@ -36,7 +36,7 @@ class TagHelperTest < ActionView::TestCase end def test_tag_options_rejects_nil_option - assert_equal "<p />", tag("p", :ignored => nil) + assert_equal "<p />", tag("p", ignored: nil) end def test_tag_builder_options_rejects_nil_option @@ -44,7 +44,7 @@ class TagHelperTest < ActionView::TestCase end def test_tag_options_accepts_false_option - assert_equal "<p value=\"false\" />", tag("p", :value => false) + assert_equal "<p value=\"false\" />", tag("p", value: false) end def test_tag_builder_options_accepts_false_option @@ -52,7 +52,7 @@ class TagHelperTest < ActionView::TestCase end def test_tag_options_accepts_blank_option - assert_equal "<p included=\"\" />", tag("p", :included => "") + assert_equal "<p included=\"\" />", tag("p", included: "") end def test_tag_builder_options_accepts_blank_option @@ -61,7 +61,7 @@ class TagHelperTest < ActionView::TestCase def test_tag_options_converts_boolean_option assert_dom_equal '<p disabled="disabled" itemscope="itemscope" multiple="multiple" readonly="readonly" allowfullscreen="allowfullscreen" seamless="seamless" typemustmatch="typemustmatch" sortable="sortable" default="default" inert="inert" truespeed="truespeed" />', - tag("p", :disabled => true, :itemscope => true, :multiple => true, :readonly => true, :allowfullscreen => true, :seamless => true, :typemustmatch => true, :sortable => true, :default => true, :inert => true, :truespeed => true) + tag("p", disabled: true, itemscope: true, multiple: true, readonly: true, allowfullscreen: true, seamless: true, typemustmatch: true, sortable: true, default: true, inert: true, truespeed: true) end def test_tag_builder_options_converts_boolean_option @@ -73,7 +73,7 @@ class TagHelperTest < ActionView::TestCase assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create") assert content_tag("a", "Create", "href" => "create").html_safe? assert_equal content_tag("a", "Create", "href" => "create"), - content_tag("a", "Create", :href => "create") + content_tag("a", "Create", href: "create") assert_equal "<p><script>evil_js</script></p>", content_tag(:p, "<script>evil_js</script>") assert_equal "<p><script>evil_js</script></p>", @@ -131,7 +131,7 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_block_and_options_out_of_erb - assert_dom_equal %(<div class="green">Hello world!</div>), content_tag(:div, :class => "green") { "Hello world!" } + assert_dom_equal %(<div class="green">Hello world!</div>), content_tag(:div, class: "green") { "Hello world!" } end def test_tag_builder_with_block_and_options_out_of_erb @@ -139,7 +139,7 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_block_and_options_outside_out_of_erb - assert_equal content_tag("a", "Create", :href => "create"), + assert_equal content_tag("a", "Create", href: "create"), content_tag("a", "href" => "create") { "Create" } end @@ -173,13 +173,13 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_escaped_array_class - str = content_tag("p", "limelight", :class => ["song", "play>"]) + str = content_tag("p", "limelight", class: ["song", "play>"]) assert_equal "<p class=\"song play>\">limelight</p>", str - str = content_tag("p", "limelight", :class => ["song", "play"]) + str = content_tag("p", "limelight", class: ["song", "play"]) assert_equal "<p class=\"song play\">limelight</p>", str - str = content_tag("p", "limelight", :class => ["song", ["play"]]) + str = content_tag("p", "limelight", class: ["song", ["play"]]) assert_equal "<p class=\"song play\">limelight</p>", str end @@ -195,10 +195,10 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_unescaped_array_class - str = content_tag("p", "limelight", {:class => ["song", "play>"]}, false) + str = content_tag("p", "limelight", {class: ["song", "play>"]}, false) assert_equal "<p class=\"song play>\">limelight</p>", str - str = content_tag("p", "limelight", {:class => ["song", ["play>"]]}, false) + str = content_tag("p", "limelight", {class: ["song", ["play>"]]}, false) assert_equal "<p class=\"song play>\">limelight</p>", str end @@ -211,7 +211,7 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_empty_array_class - str = content_tag("p", "limelight", {:class => []}) + str = content_tag("p", "limelight", {class: []}) assert_equal '<p class="">limelight</p>', str end @@ -220,7 +220,7 @@ class TagHelperTest < ActionView::TestCase end def test_content_tag_with_unescaped_empty_array_class - str = content_tag("p", "limelight", {:class => []}, false) + str = content_tag("p", "limelight", {class: []}, false) assert_equal '<p class="">limelight</p>', str end @@ -259,14 +259,14 @@ class TagHelperTest < ActionView::TestCase def test_tag_honors_html_safe_for_param_values ["1&2", "1 < 2", "“test“"].each do |escaped| - assert_equal %(<a href="#{escaped}" />), tag("a", :href => escaped.html_safe) + assert_equal %(<a href="#{escaped}" />), tag("a", href: escaped.html_safe) assert_equal %(<a href="#{escaped}"></a>), tag.a(href: escaped.html_safe) end end def test_tag_honors_html_safe_with_escaped_array_class - assert_equal '<p class="song> play>" />', tag("p", :class => ["song>", raw("play>")]) - assert_equal '<p class="song> play>" />', tag("p", :class => [raw("song>"), "play>"]) + assert_equal '<p class="song> play>" />', tag("p", class: ["song>", raw("play>")]) + assert_equal '<p class="song> play>" />', tag("p", class: [raw("song>"), "play>"]) end def test_tag_builder_honors_html_safe_with_escaped_array_class @@ -276,13 +276,13 @@ class TagHelperTest < ActionView::TestCase def test_skip_invalid_escaped_attributes ["&1;", "dfa3;", "& #123;"].each do |escaped| - assert_equal %(<a href="#{escaped.gsub(/&/, '&')}" />), tag("a", :href => escaped) + assert_equal %(<a href="#{escaped.gsub(/&/, '&')}" />), tag("a", href: escaped) assert_equal %(<a href="#{escaped.gsub(/&/, '&')}"></a>), tag.a(href: escaped) end end def test_disable_escaping - assert_equal '<a href="&" />', tag("a", { :href => "&" }, false, false) + assert_equal '<a href="&" />', tag("a", { href: "&" }, false, false) end def test_tag_builder_disable_escaping |