From 4b6c68dfb810c836f87587a16353317d1a180805 Mon Sep 17 00:00:00 2001 From: Xavier Noria Date: Sat, 6 Aug 2016 18:50:17 +0200 Subject: applies new string literal convention in actionview/test The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default. --- .../test/template/active_model_helper_test.rb | 6 +- actionview/test/template/asset_tag_helper_test.rb | 96 +++--- actionview/test/template/atom_feed_helper_test.rb | 12 +- actionview/test/template/capture_helper_test.rb | 98 +++--- .../test/template/compiled_templates_test.rb | 2 +- actionview/test/template/controller_helper_test.rb | 2 +- actionview/test/template/date_helper_i18n_test.rb | 72 ++--- actionview/test/template/date_helper_test.rb | 152 ++++----- .../test/template/dependency_tracker_test.rb | 4 +- actionview/test/template/digestor_test.rb | 14 +- actionview/test/template/erb_util_test.rb | 24 +- .../test/template/form_collections_helper_test.rb | 340 ++++++++++----------- actionview/test/template/form_helper_test.rb | 324 ++++++++++---------- .../test/template/form_options_helper_i18n_test.rb | 10 +- .../test/template/form_options_helper_test.rb | 122 ++++---- actionview/test/template/form_tag_helper_test.rb | 36 +-- actionview/test/template/html_test.rb | 14 +- actionview/test/template/javascript_helper_test.rb | 14 +- actionview/test/template/log_subscriber_test.rb | 6 +- actionview/test/template/number_helper_test.rb | 46 +-- .../test/template/output_safety_helper_test.rb | 34 +-- actionview/test/template/partial_iteration_test.rb | 4 +- actionview/test/template/record_identifier_test.rb | 12 +- actionview/test/template/record_tag_helper_test.rb | 2 +- actionview/test/template/render_test.rb | 82 ++--- actionview/test/template/resolver_cache_test.rb | 2 +- actionview/test/template/resolver_patterns_test.rb | 2 +- actionview/test/template/sanitize_helper_test.rb | 4 +- actionview/test/template/streaming_render_test.rb | 6 +- actionview/test/template/tag_helper_test.rb | 90 +++--- actionview/test/template/test_case_test.rb | 92 +++--- actionview/test/template/test_test.rb | 8 +- .../test/template/testing/fixture_resolver_test.rb | 2 +- .../test/template/testing/null_resolver_test.rb | 2 +- actionview/test/template/text_helper_test.rb | 84 ++--- actionview/test/template/text_test.rb | 14 +- .../test/template/translation_helper_test.rb | 76 ++--- actionview/test/template/url_helper_test.rb | 156 +++++----- 38 files changed, 1033 insertions(+), 1033 deletions(-) (limited to 'actionview/test/template') diff --git a/actionview/test/template/active_model_helper_test.rb b/actionview/test/template/active_model_helper_test.rb index 55d62cf692..aa708b6706 100644 --- a/actionview/test/template/active_model_helper_test.rb +++ b/actionview/test/template/active_model_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ActiveModelHelperTest < ActionView::TestCase tests ActionView::Helpers::ActiveModelHelper @@ -50,8 +50,8 @@ class ActiveModelHelperTest < ActionView::TestCase def test_select_with_errors_and_blank_option expected_dom = %(
) - assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :include_blank => 'Choose one...')) - assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :prompt => 'Choose one...')) + assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :include_blank => "Choose one...")) + assert_dom_equal(expected_dom, select("post", "author_name", [:a, :b], :prompt => "Choose one...")) end def test_date_select_with_errors diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb index 1a1b6f5e2d..226bb236c6 100644 --- a/actionview/test/template/asset_tag_helper_test.rb +++ b/actionview/test/template/asset_tag_helper_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'active_support/ordered_options' +require "abstract_unit" +require "active_support/ordered_options" class AssetTagHelperTest < ActionView::TestCase tests ActionView::Helpers::AssetTagHelper @@ -13,10 +13,10 @@ class AssetTagHelperTest < ActionView::TestCase @request = Class.new do attr_accessor :script_name - def protocol() 'http://' end + def protocol() "http://" end def ssl?() false end - def host_with_port() 'localhost' end - def base_url() 'http://www.example.com' end + def host_with_port() "localhost" end + def base_url() "http://www.example.com" end end.new @controller.request = @request @@ -306,7 +306,7 @@ class AssetTagHelperTest < ActionView::TestCase end def test_autodiscovery_link_tag_with_unknown_type - result = auto_discovery_link_tag(:xml, '/feed.xml', :type => 'application/xml') + result = auto_discovery_link_tag(:xml, "/feed.xml", :type => "application/xml") expected = %() assert_dom_equal expected, result end @@ -322,10 +322,10 @@ class AssetTagHelperTest < ActionView::TestCase def test_asset_path_tag_to_not_create_duplicate_slashes @controller.config.asset_host = "host/" - assert_dom_equal('http://host/foo', asset_path("foo")) + assert_dom_equal("http://host/foo", asset_path("foo")) - @controller.config.relative_url_root = '/some/root/' - assert_dom_equal('http://host/some/root/foo', asset_path("foo")) + @controller.config.relative_url_root = "/some/root/" + assert_dom_equal("http://host/some/root/foo", asset_path("foo")) end def test_compute_asset_public_path @@ -362,11 +362,11 @@ class AssetTagHelperTest < ActionView::TestCase def test_javascript_include_tag_with_missing_source assert_nothing_raised { - javascript_include_tag('missing_security_guard') + javascript_include_tag("missing_security_guard") } assert_nothing_raised { - javascript_include_tag('http://example.com/css/missing_security_guard') + javascript_include_tag("http://example.com/css/missing_security_guard") } end @@ -376,13 +376,13 @@ class AssetTagHelperTest < ActionView::TestCase def test_javascript_include_tag_relative_protocol @controller.config.asset_host = "assets.example.com" - assert_dom_equal %(), javascript_include_tag('prototype', protocol: :relative) + assert_dom_equal %(), javascript_include_tag("prototype", protocol: :relative) end def test_javascript_include_tag_default_protocol @controller.config.asset_host = "assets.example.com" @controller.config.default_asset_host_protocol = :relative - assert_dom_equal %(), javascript_include_tag('prototype') + assert_dom_equal %(), javascript_include_tag("prototype") end def test_stylesheet_path @@ -407,36 +407,36 @@ class AssetTagHelperTest < ActionView::TestCase def test_stylesheet_link_tag_with_missing_source assert_nothing_raised { - stylesheet_link_tag('missing_security_guard') + stylesheet_link_tag("missing_security_guard") } assert_nothing_raised { - stylesheet_link_tag('http://example.com/css/missing_security_guard') + stylesheet_link_tag("http://example.com/css/missing_security_guard") } end def test_stylesheet_link_tag_is_html_safe - assert stylesheet_link_tag('dir/file').html_safe? - assert stylesheet_link_tag('dir/other/file', 'dir/file2').html_safe? + assert stylesheet_link_tag("dir/file").html_safe? + assert stylesheet_link_tag("dir/other/file", "dir/file2").html_safe? end def test_stylesheet_link_tag_escapes_options - assert_dom_equal %(), stylesheet_link_tag('/file', :media => '', - '<script type="application/javascript">alert("You are 'pwned'!")</script>' + "<script type="application/javascript">alert("You are 'pwned'!")</script>" ] ] JSON_ESCAPE_TEST_CASES = [ - ['1', '1'], - ['null', 'null'], + ["1", "1"], + ["null", "null"], ['"&"', '"\u0026"'], ['""', '"\u003c/script\u003e"'], ['[""]', '["\u003c/script\u003e"]'], @@ -91,17 +91,17 @@ class ErbUtilTest < ActiveSupport::TestCase end def test_html_escape_once - assert_equal '1 <>&"' 2 & 3', html_escape_once('1 <>&"\' 2 & 3') + assert_equal "1 <>&"' 2 & 3", html_escape_once('1 <>&"\' 2 & 3') assert_equal " ' ' λ λ " ' < > ", html_escape_once(" ' ' λ λ \" ' < > ") end def test_html_escape_once_returns_unsafe_strings_when_passed_unsafe_strings - value = html_escape_once('1 < 2 & 3') + value = html_escape_once("1 < 2 & 3") assert !value.html_safe? end def test_html_escape_once_returns_safe_strings_when_passed_safe_strings - value = html_escape_once('1 < 2 & 3'.html_safe) + value = html_escape_once("1 < 2 & 3".html_safe) assert value.html_safe? end end diff --git a/actionview/test/template/form_collections_helper_test.rb b/actionview/test/template/form_collections_helper_test.rb index 4f7ea88169..4a4b3a2c16 100644 --- a/actionview/test/template/form_collections_helper_test.rb +++ b/actionview/test/template/form_collections_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class Category < Struct.new(:id, :name) end @@ -17,170 +17,170 @@ class FormCollectionsHelperTest < ActionView::TestCase end # COLLECTION RADIO BUTTONS - test 'collection radio accepts a collection and generates inputs from value method' do + test "collection radio accepts a collection and generates inputs from value method" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s - assert_select 'input[type=radio][value=true]#user_active_true' - assert_select 'input[type=radio][value=false]#user_active_false' + assert_select "input[type=radio][value=true]#user_active_true" + assert_select "input[type=radio][value=false]#user_active_false" end - test 'collection radio accepts a collection and generates inputs from label method' do + test "collection radio accepts a collection and generates inputs from label method" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s - assert_select 'label[for=user_active_true]', 'true' - assert_select 'label[for=user_active_false]', 'false' + assert_select "label[for=user_active_true]", "true" + assert_select "label[for=user_active_false]", "false" end - test 'collection radio handles camelized collection values for labels correctly' do - with_collection_radio_buttons :user, :active, ['Yes', 'No'], :to_s, :to_s + test "collection radio handles camelized collection values for labels correctly" do + with_collection_radio_buttons :user, :active, ["Yes", "No"], :to_s, :to_s - assert_select 'label[for=user_active_yes]', 'Yes' - assert_select 'label[for=user_active_no]', 'No' + assert_select "label[for=user_active_yes]", "Yes" + assert_select "label[for=user_active_no]", "No" end - test 'collection radio should sanitize collection values for labels correctly' do - with_collection_radio_buttons :user, :name, ['$0.99', '$1.99'], :to_s, :to_s - assert_select 'label[for=user_name_099]', '$0.99' - assert_select 'label[for=user_name_199]', '$1.99' + test "collection radio should sanitize collection values for labels correctly" do + with_collection_radio_buttons :user, :name, ["$0.99", "$1.99"], :to_s, :to_s + assert_select "label[for=user_name_099]", "$0.99" + assert_select "label[for=user_name_199]", "$1.99" end - test 'collection radio accepts checked item' do + test "collection radio accepts checked item" do with_collection_radio_buttons :user, :active, [[1, true], [0, false]], :last, :first, :checked => true - assert_select 'input[type=radio][value=true][checked=checked]' - assert_no_select 'input[type=radio][value=false][checked=checked]' + assert_select "input[type=radio][value=true][checked=checked]" + assert_no_select "input[type=radio][value=false][checked=checked]" end - test 'collection radio accepts multiple disabled items' do - collection = [[1, true], [0, false], [2, 'other']] + test "collection radio accepts multiple disabled items" do + collection = [[1, true], [0, false], [2, "other"]] with_collection_radio_buttons :user, :active, collection, :last, :first, :disabled => [true, false] - assert_select 'input[type=radio][value=true][disabled=disabled]' - assert_select 'input[type=radio][value=false][disabled=disabled]' - assert_no_select 'input[type=radio][value=other][disabled=disabled]' + assert_select "input[type=radio][value=true][disabled=disabled]" + assert_select "input[type=radio][value=false][disabled=disabled]" + assert_no_select "input[type=radio][value=other][disabled=disabled]" end - test 'collection radio accepts single disabled item' do + test "collection radio accepts single disabled item" do collection = [[1, true], [0, false]] with_collection_radio_buttons :user, :active, collection, :last, :first, :disabled => true - assert_select 'input[type=radio][value=true][disabled=disabled]' - assert_no_select 'input[type=radio][value=false][disabled=disabled]' + assert_select "input[type=radio][value=true][disabled=disabled]" + assert_no_select "input[type=radio][value=false][disabled=disabled]" end - test 'collection radio accepts multiple readonly items' do - collection = [[1, true], [0, false], [2, 'other']] + test "collection radio accepts multiple readonly items" do + collection = [[1, true], [0, false], [2, "other"]] with_collection_radio_buttons :user, :active, collection, :last, :first, :readonly => [true, false] - assert_select 'input[type=radio][value=true][readonly=readonly]' - assert_select 'input[type=radio][value=false][readonly=readonly]' - assert_no_select 'input[type=radio][value=other][readonly=readonly]' + assert_select "input[type=radio][value=true][readonly=readonly]" + assert_select "input[type=radio][value=false][readonly=readonly]" + assert_no_select "input[type=radio][value=other][readonly=readonly]" end - test 'collection radio accepts single readonly item' do + test "collection radio accepts single readonly item" do collection = [[1, true], [0, false]] with_collection_radio_buttons :user, :active, collection, :last, :first, :readonly => true - assert_select 'input[type=radio][value=true][readonly=readonly]' - assert_no_select 'input[type=radio][value=false][readonly=readonly]' + assert_select "input[type=radio][value=true][readonly=readonly]" + assert_no_select "input[type=radio][value=false][readonly=readonly]" end - test 'collection radio accepts html options as input' do + test "collection radio accepts html options as input" do collection = [[1, true], [0, false]] - with_collection_radio_buttons :user, :active, collection, :last, :first, {}, :class => 'special-radio' + with_collection_radio_buttons :user, :active, collection, :last, :first, {}, :class => "special-radio" - assert_select 'input[type=radio][value=true].special-radio#user_active_true' - assert_select 'input[type=radio][value=false].special-radio#user_active_false' + assert_select "input[type=radio][value=true].special-radio#user_active_true" + assert_select "input[type=radio][value=false].special-radio#user_active_false" end - test 'collection radio accepts html options as the last element of array' do - collection = [[1, true, {class: 'foo'}], [0, false, {class: 'bar'}]] + test "collection radio accepts html options as the last element of array" do + collection = [[1, true, {class: "foo"}], [0, false, {class: "bar"}]] with_collection_radio_buttons :user, :active, collection, :second, :first - assert_select 'input[type=radio][value=true].foo#user_active_true' - assert_select 'input[type=radio][value=false].bar#user_active_false' + assert_select "input[type=radio][value=true].foo#user_active_true" + assert_select "input[type=radio][value=false].bar#user_active_false" end - test 'collection radio sets the label class defined inside the block' do - collection = [[1, true, {class: 'foo'}], [0, false, {class: 'bar'}]] + test "collection radio sets the label class defined inside the block" do + collection = [[1, true, {class: "foo"}], [0, false, {class: "bar"}]] with_collection_radio_buttons :user, :active, collection, :second, :first do |b| b.label(class: "collection_radio_buttons") end - assert_select 'label.collection_radio_buttons[for=user_active_true]' - assert_select 'label.collection_radio_buttons[for=user_active_false]' + assert_select "label.collection_radio_buttons[for=user_active_true]" + assert_select "label.collection_radio_buttons[for=user_active_false]" end - test 'collection radio does not include the input class in the respective label' do - collection = [[1, true, {class: 'foo'}], [0, false, {class: 'bar'}]] + test "collection radio does not include the input class in the respective label" do + collection = [[1, true, {class: "foo"}], [0, false, {class: "bar"}]] with_collection_radio_buttons :user, :active, collection, :second, :first - assert_no_select 'label.foo[for=user_active_true]' - assert_no_select 'label.bar[for=user_active_false]' + assert_no_select "label.foo[for=user_active_true]" + assert_no_select "label.bar[for=user_active_false]" end - test 'collection radio does not wrap input inside the label' do + test "collection radio does not wrap input inside the label" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s - assert_select 'input[type=radio] + label' - assert_no_select 'label input' + assert_select "input[type=radio] + label" + assert_no_select "label input" end - test 'collection radio accepts a block to render the label as radio button wrapper' do + test "collection radio accepts a block to render the label as radio button wrapper" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label { b.radio_button } end - assert_select 'label[for=user_active_true] > input#user_active_true[type=radio]' - assert_select 'label[for=user_active_false] > input#user_active_false[type=radio]' + assert_select "label[for=user_active_true] > input#user_active_true[type=radio]" + assert_select "label[for=user_active_false] > input#user_active_false[type=radio]" end - test 'collection radio accepts a block to change the order of label and radio button' do + test "collection radio accepts a block to change the order of label and radio button" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label + b.radio_button end - assert_select 'label[for=user_active_true] + input#user_active_true[type=radio]' - assert_select 'label[for=user_active_false] + input#user_active_false[type=radio]' + assert_select "label[for=user_active_true] + input#user_active_true[type=radio]" + assert_select "label[for=user_active_false] + input#user_active_false[type=radio]" end - test 'collection radio with block helpers accept extra html options' do + test "collection radio with block helpers accept extra html options" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label(:class => "radio_button") + b.radio_button(:class => "radio_button") end - assert_select 'label.radio_button[for=user_active_true] + input#user_active_true.radio_button[type=radio]' - assert_select 'label.radio_button[for=user_active_false] + input#user_active_false.radio_button[type=radio]' + assert_select "label.radio_button[for=user_active_true] + input#user_active_true.radio_button[type=radio]" + assert_select "label.radio_button[for=user_active_false] + input#user_active_false.radio_button[type=radio]" end - test 'collection radio with block helpers allows access to current text and value' do + test "collection radio with block helpers allows access to current text and value" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label(:"data-value" => b.value) { b.radio_button + b.text } end - assert_select 'label[for=user_active_true][data-value=true]', 'true' do - assert_select 'input#user_active_true[type=radio]' + assert_select "label[for=user_active_true][data-value=true]", "true" do + assert_select "input#user_active_true[type=radio]" end - assert_select 'label[for=user_active_false][data-value=false]', 'false' do - assert_select 'input#user_active_false[type=radio]' + assert_select "label[for=user_active_false][data-value=false]", "false" do + assert_select "input#user_active_false[type=radio]" end end - test 'collection radio with block helpers allows access to the current object item in the collection to access extra properties' do + test "collection radio with block helpers allows access to the current object item in the collection to access extra properties" do with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s do |b| b.label(:class => b.object) { b.radio_button + b.text } end - assert_select 'label.true[for=user_active_true]', 'true' do - assert_select 'input#user_active_true[type=radio]' + assert_select "label.true[for=user_active_true]", "true" do + assert_select "input#user_active_true[type=radio]" end - assert_select 'label.false[for=user_active_false]', 'false' do - assert_select 'input#user_active_false[type=radio]' + assert_select "label.false[for=user_active_false]", "false" do + assert_select "input#user_active_false[type=radio]" end end - test 'collection radio buttons with fields for' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection radio buttons with fields for" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] @output_buffer = fields_for(:post) do |p| p.collection_radio_buttons :category_id, collection, :id, :name end @@ -188,154 +188,154 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'input#post_category_id_1[type=radio][value="1"]' assert_select 'input#post_category_id_2[type=radio][value="2"]' - assert_select 'label[for=post_category_id_1]', 'Category 1' - assert_select 'label[for=post_category_id_2]', 'Category 2' + assert_select "label[for=post_category_id_1]", "Category 1" + assert_select "label[for=post_category_id_2]", "Category 2" end - test 'collection radio accepts checked item which has a value of false' do + test "collection radio accepts checked item which has a value of false" do with_collection_radio_buttons :user, :active, [[1, true], [0, false]], :last, :first, :checked => false - assert_no_select 'input[type=radio][value=true][checked=checked]' - assert_select 'input[type=radio][value=false][checked=checked]' + assert_no_select "input[type=radio][value=true][checked=checked]" + assert_select "input[type=radio][value=false][checked=checked]" end - test 'collection radio buttons generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection radio buttons generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_radio_buttons :user, :category_ids, collection, :id, :name assert_select "input[type=hidden][name='user[category_ids]'][value='']", count: 1 end - test 'collection radio buttons generates a hidden field using the given :name in :html_options' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection radio buttons generates a hidden field using the given :name in :html_options" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_radio_buttons :user, :category_ids, collection, :id, :name, {}, { name: "user[other_category_ids]" } assert_select "input[type=hidden][name='user[other_category_ids]'][value='']", count: 1 end - test 'collection radio buttons generates a hidden field with index if it was provided' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection radio buttons generates a hidden field with index if it was provided" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_radio_buttons :user, :category_ids, collection, :id, :name, { index: 322 } assert_select "input[type=hidden][name='user[322][category_ids]'][value='']", count: 1 end - test 'collection radio buttons does not generate a hidden field if include_hidden option is false' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection radio buttons does not generate a hidden field if include_hidden option is false" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_radio_buttons :user, :category_ids, collection, :id, :name, include_hidden: false assert_select "input[type=hidden][name='user[category_ids]'][value='']", count: 0 end - test 'collection radio buttons does not generate a hidden field if include_hidden option is false with key as string' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] - with_collection_radio_buttons :user, :category_ids, collection, :id, :name, 'include_hidden' => false + test "collection radio buttons does not generate a hidden field if include_hidden option is false with key as string" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] + with_collection_radio_buttons :user, :category_ids, collection, :id, :name, "include_hidden" => false assert_select "input[type=hidden][name='user[category_ids]'][value='']", count: 0 end # COLLECTION CHECK BOXES - test 'collection check boxes accepts a collection and generate a series of checkboxes for value method' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes accepts a collection and generate a series of checkboxes for value method" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name assert_select 'input#user_category_ids_1[type=checkbox][value="1"]' assert_select 'input#user_category_ids_2[type=checkbox][value="2"]' end - test 'collection check boxes generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes generates only one hidden field for the entire collection, to ensure something will be sent back to the server when posting an empty collection" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name assert_select "input[type=hidden][name='user[category_ids][]'][value='']", :count => 1 end - test 'collection check boxes generates a hidden field using the given :name in :html_options' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes generates a hidden field using the given :name in :html_options" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name, {}, {name: "user[other_category_ids][]"} assert_select "input[type=hidden][name='user[other_category_ids][]'][value='']", :count => 1 end - test 'collection check boxes generates a hidden field with index if it was provided' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes generates a hidden field with index if it was provided" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name, { index: 322 } assert_select "input[type=hidden][name='user[322][category_ids][]'][value='']", count: 1 end - test 'collection check boxes does not generate a hidden field if include_hidden option is false' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes does not generate a hidden field if include_hidden option is false" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name, include_hidden: false assert_select "input[type=hidden][name='user[category_ids][]'][value='']", :count => 0 end - test 'collection check boxes does not generate a hidden field if include_hidden option is false with key as string' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] - with_collection_check_boxes :user, :category_ids, collection, :id, :name, 'include_hidden' => false + test "collection check boxes does not generate a hidden field if include_hidden option is false with key as string" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] + with_collection_check_boxes :user, :category_ids, collection, :id, :name, "include_hidden" => false assert_select "input[type=hidden][name='user[category_ids][]'][value='']", count: 0 end - test 'collection check boxes accepts a collection and generate a series of checkboxes with labels for label method' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes accepts a collection and generate a series of checkboxes with labels for label method" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] with_collection_check_boxes :user, :category_ids, collection, :id, :name - assert_select 'label[for=user_category_ids_1]', 'Category 1' - assert_select 'label[for=user_category_ids_2]', 'Category 2' + assert_select "label[for=user_category_ids_1]", "Category 1" + assert_select "label[for=user_category_ids_2]", "Category 2" end - test 'collection check boxes handles camelized collection values for labels correctly' do - with_collection_check_boxes :user, :active, ['Yes', 'No'], :to_s, :to_s + test "collection check boxes handles camelized collection values for labels correctly" do + with_collection_check_boxes :user, :active, ["Yes", "No"], :to_s, :to_s - assert_select 'label[for=user_active_yes]', 'Yes' - assert_select 'label[for=user_active_no]', 'No' + assert_select "label[for=user_active_yes]", "Yes" + assert_select "label[for=user_active_no]", "No" end - test 'collection check box should sanitize collection values for labels correctly' do - with_collection_check_boxes :user, :name, ['$0.99', '$1.99'], :to_s, :to_s - assert_select 'label[for=user_name_099]', '$0.99' - assert_select 'label[for=user_name_199]', '$1.99' + test "collection check box should sanitize collection values for labels correctly" do + with_collection_check_boxes :user, :name, ["$0.99", "$1.99"], :to_s, :to_s + assert_select "label[for=user_name_099]", "$0.99" + assert_select "label[for=user_name_199]", "$1.99" end - test 'collection check boxes accepts html options as the last element of array' do - collection = [[1, 'Category 1', {class: 'foo'}], [2, 'Category 2', {class: 'bar'}]] + test "collection check boxes accepts html options as the last element of array" do + collection = [[1, "Category 1", {class: "foo"}], [2, "Category 2", {class: "bar"}]] with_collection_check_boxes :user, :active, collection, :first, :second assert_select 'input[type=checkbox][value="1"].foo' assert_select 'input[type=checkbox][value="2"].bar' end - test 'collection check boxes propagates input id to the label for attribute' do - collection = [[1, 'Category 1', {id: 'foo'}], [2, 'Category 2', {id: 'bar'}]] + test "collection check boxes propagates input id to the label for attribute" do + collection = [[1, "Category 1", {id: "foo"}], [2, "Category 2", {id: "bar"}]] with_collection_check_boxes :user, :active, collection, :first, :second assert_select 'input[type=checkbox][value="1"]#foo' assert_select 'input[type=checkbox][value="2"]#bar' - assert_select 'label[for=foo]' - assert_select 'label[for=bar]' + assert_select "label[for=foo]" + assert_select "label[for=bar]" end - test 'collection check boxes sets the label class defined inside the block' do - collection = [[1, 'Category 1', {class: 'foo'}], [2, 'Category 2', {class: 'bar'}]] + test "collection check boxes sets the label class defined inside the block" do + collection = [[1, "Category 1", {class: "foo"}], [2, "Category 2", {class: "bar"}]] with_collection_check_boxes :user, :active, collection, :second, :first do |b| - b.label(class: 'collection_check_boxes') + b.label(class: "collection_check_boxes") end - assert_select 'label.collection_check_boxes[for=user_active_category_1]' - assert_select 'label.collection_check_boxes[for=user_active_category_2]' + assert_select "label.collection_check_boxes[for=user_active_category_1]" + assert_select "label.collection_check_boxes[for=user_active_category_2]" end - test 'collection check boxes does not include the input class in the respective label' do - collection = [[1, 'Category 1', {class: 'foo'}], [2, 'Category 2', {class: 'bar'}]] + test "collection check boxes does not include the input class in the respective label" do + collection = [[1, "Category 1", {class: "foo"}], [2, "Category 2", {class: "bar"}]] with_collection_check_boxes :user, :active, collection, :second, :first - assert_no_select 'label.foo[for=user_active_category_1]' - assert_no_select 'label.bar[for=user_active_category_2]' + assert_no_select "label.foo[for=user_active_category_1]" + assert_no_select "label.bar[for=user_active_category_2]" end - test 'collection check boxes accepts selected values as :checked option' do + test "collection check boxes accepts selected values as :checked option" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :checked => [1, 3] @@ -344,16 +344,16 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][checked=checked]' end - test 'collection check boxes accepts selected string values as :checked option' do + test "collection check boxes accepts selected string values as :checked option" do collection = (1..3).map{|i| [i, "Category #{i}"] } - with_collection_check_boxes :user, :category_ids, collection, :first, :last, :checked => ['1', '3'] + with_collection_check_boxes :user, :category_ids, collection, :first, :last, :checked => ["1", "3"] assert_select 'input[type=checkbox][value="1"][checked=checked]' assert_select 'input[type=checkbox][value="3"][checked=checked]' assert_no_select 'input[type=checkbox][value="2"][checked=checked]' end - test 'collection check boxes accepts a single checked value' do + test "collection check boxes accepts a single checked value" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :checked => 3 @@ -362,7 +362,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][checked=checked]' end - test 'collection check boxes accepts selected values as :checked option and override the model values' do + test "collection check boxes accepts selected values as :checked option and override the model values" do user = Struct.new(:category_ids).new(2) collection = (1..3).map{|i| [i, "Category #{i}"] } @@ -375,7 +375,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][checked=checked]' end - test 'collection check boxes accepts multiple disabled items' do + test "collection check boxes accepts multiple disabled items" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :disabled => [1, 3] @@ -384,7 +384,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][disabled=disabled]' end - test 'collection check boxes accepts single disabled item' do + test "collection check boxes accepts single disabled item" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :disabled => 1 @@ -393,7 +393,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][disabled=disabled]' end - test 'collection check boxes accepts a proc to disabled items' do + test "collection check boxes accepts a proc to disabled items" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :disabled => proc { |i| i.first == 1 } @@ -402,7 +402,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][disabled=disabled]' end - test 'collection check boxes accepts multiple readonly items' do + test "collection check boxes accepts multiple readonly items" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => [1, 3] @@ -411,7 +411,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]' end - test 'collection check boxes accepts single readonly item' do + test "collection check boxes accepts single readonly item" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => 1 @@ -420,7 +420,7 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]' end - test 'collection check boxes accepts a proc to readonly items' do + test "collection check boxes accepts a proc to readonly items" do collection = (1..3).map{|i| [i, "Category #{i}"] } with_collection_check_boxes :user, :category_ids, collection, :first, :last, :readonly => proc { |i| i.first == 1 } @@ -429,16 +429,16 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_no_select 'input[type=checkbox][value="2"][readonly=readonly]' end - test 'collection check boxes accepts html options' do - collection = [[1, 'Category 1'], [2, 'Category 2']] - with_collection_check_boxes :user, :category_ids, collection, :first, :last, {}, :class => 'check' + test "collection check boxes accepts html options" do + collection = [[1, "Category 1"], [2, "Category 2"]] + with_collection_check_boxes :user, :category_ids, collection, :first, :last, {}, :class => "check" assert_select 'input.check[type=checkbox][value="1"]' assert_select 'input.check[type=checkbox][value="2"]' end - test 'collection check boxes with fields for' do - collection = [Category.new(1, 'Category 1'), Category.new(2, 'Category 2')] + test "collection check boxes with fields for" do + collection = [Category.new(1, "Category 1"), Category.new(2, "Category 2")] @output_buffer = fields_for(:post) do |p| p.collection_check_boxes :category_ids, collection, :id, :name end @@ -446,67 +446,67 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select 'input#post_category_ids_1[type=checkbox][value="1"]' assert_select 'input#post_category_ids_2[type=checkbox][value="2"]' - assert_select 'label[for=post_category_ids_1]', 'Category 1' - assert_select 'label[for=post_category_ids_2]', 'Category 2' + assert_select "label[for=post_category_ids_1]", "Category 1" + assert_select "label[for=post_category_ids_2]", "Category 2" end - test 'collection check boxes does not wrap input inside the label' do + test "collection check boxes does not wrap input inside the label" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s - assert_select 'input[type=checkbox] + label' - assert_no_select 'label input' + assert_select "input[type=checkbox] + label" + assert_no_select "label input" end - test 'collection check boxes accepts a block to render the label as check box wrapper' do + test "collection check boxes accepts a block to render the label as check box wrapper" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label { b.check_box } end - assert_select 'label[for=user_active_true] > input#user_active_true[type=checkbox]' - assert_select 'label[for=user_active_false] > input#user_active_false[type=checkbox]' + assert_select "label[for=user_active_true] > input#user_active_true[type=checkbox]" + assert_select "label[for=user_active_false] > input#user_active_false[type=checkbox]" end - test 'collection check boxes accepts a block to change the order of label and check box' do + test "collection check boxes accepts a block to change the order of label and check box" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label + b.check_box end - assert_select 'label[for=user_active_true] + input#user_active_true[type=checkbox]' - assert_select 'label[for=user_active_false] + input#user_active_false[type=checkbox]' + assert_select "label[for=user_active_true] + input#user_active_true[type=checkbox]" + assert_select "label[for=user_active_false] + input#user_active_false[type=checkbox]" end - test 'collection check boxes with block helpers accept extra html options' do + test "collection check boxes with block helpers accept extra html options" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label(:class => "check_box") + b.check_box(:class => "check_box") end - assert_select 'label.check_box[for=user_active_true] + input#user_active_true.check_box[type=checkbox]' - assert_select 'label.check_box[for=user_active_false] + input#user_active_false.check_box[type=checkbox]' + assert_select "label.check_box[for=user_active_true] + input#user_active_true.check_box[type=checkbox]" + assert_select "label.check_box[for=user_active_false] + input#user_active_false.check_box[type=checkbox]" end - test 'collection check boxes with block helpers allows access to current text and value' do + test "collection check boxes with block helpers allows access to current text and value" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label(:"data-value" => b.value) { b.check_box + b.text } end - assert_select 'label[for=user_active_true][data-value=true]', 'true' do - assert_select 'input#user_active_true[type=checkbox]' + assert_select "label[for=user_active_true][data-value=true]", "true" do + assert_select "input#user_active_true[type=checkbox]" end - assert_select 'label[for=user_active_false][data-value=false]', 'false' do - assert_select 'input#user_active_false[type=checkbox]' + assert_select "label[for=user_active_false][data-value=false]", "false" do + assert_select "input#user_active_false[type=checkbox]" end end - test 'collection check boxes with block helpers allows access to the current object item in the collection to access extra properties' do + test "collection check boxes with block helpers allows access to the current object item in the collection to access extra properties" do with_collection_check_boxes :user, :active, [true, false], :to_s, :to_s do |b| b.label(:class => b.object) { b.check_box + b.text } end - assert_select 'label.true[for=user_active_true]', 'true' do - assert_select 'input#user_active_true[type=checkbox]' + assert_select "label.true[for=user_active_true]", "true" do + assert_select "input#user_active_true[type=checkbox]" end - assert_select 'label.false[for=user_active_false]', 'false' do - assert_select 'input#user_active_false[type=checkbox]' + assert_select "label.false[for=user_active_false]", "false" do + assert_select "input#user_active_false[type=checkbox]" end end end diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb index 54da2b0c9c..9ac78d8718 100644 --- a/actionview/test/template/form_helper_test.rb +++ b/actionview/test/template/form_helper_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'controller/fake_models' +require "abstract_unit" +require "controller/fake_models" class FormHelperTest < ActionView::TestCase include RenderERBUtils @@ -16,7 +16,7 @@ class FormHelperTest < ActionView::TestCase setup do # Create "label" locale for testing I18n label helpers - I18n.backend.store_translations 'label', { + I18n.backend.store_translations "label", { activemodel: { attributes: { post: { @@ -42,27 +42,27 @@ class FormHelperTest < ActionView::TestCase value: "Tag" }, post_delegate: { - title: 'Delegate model_name title' + title: "Delegate model_name title" } } } } # Create "submit" locale for testing I18n submit helpers - I18n.backend.store_translations 'submit', { + I18n.backend.store_translations "submit", { helpers: { submit: { - create: 'Create %{model}', - update: 'Confirm %{model} changes', - submit: 'Save changes', + create: "Create %{model}", + update: "Confirm %{model} changes", + submit: "Save changes", another_post: { - update: 'Update your %{model}' + update: "Update your %{model}" } } } } - I18n.backend.store_translations 'placeholder', { + I18n.backend.store_translations "placeholder", { activemodel: { attributes: { post: { @@ -85,7 +85,7 @@ class FormHelperTest < ActionView::TestCase } }, post_delegate: { - title: 'Delegate model_name title' + title: "Delegate model_name title" }, tag: { value: "Tag" @@ -108,7 +108,7 @@ class FormHelperTest < ActionView::TestCase def @post.id; 0; end def @post.id_before_type_cast; "omg"; end def @post.id_came_from_user?; true; end - def @post.to_param; '123'; end + def @post.to_param; "123"; end @post.persisted = true @post.title = "Hello World" @@ -125,7 +125,7 @@ class FormHelperTest < ActionView::TestCase @post_delegator = PostDelegator.new - @post_delegator.title = 'Hello World' + @post_delegator.title = "Hello World" @car = Car.new("#000FFF") end @@ -178,7 +178,7 @@ class FormHelperTest < ActionView::TestCase ) assert_dom_equal( '', - label("post", "title", nil, class: 'title_label') + label("post", "title", nil, class: "title_label") ) assert_dom_equal('', label("post", "secret?")) end @@ -229,7 +229,7 @@ class FormHelperTest < ActionView::TestCase def test_label_with_locales_and_nested_attributes with_locale :label do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:comments) do |cf| concat cf.label(:body) end @@ -245,7 +245,7 @@ class FormHelperTest < ActionView::TestCase def test_label_with_locales_fallback_and_nested_attributes with_locale :label do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:tags) do |cf| concat cf.label(:value) end @@ -260,7 +260,7 @@ class FormHelperTest < ActionView::TestCase end def test_label_with_non_active_record_object - form_for(OpenStruct.new(name:'ok'), as: 'person', url: 'an_url', html: { id: 'create-person' }) do |f| + form_for(OpenStruct.new(name:"ok"), as: "person", url: "an_url", html: { id: "create-person" }) do |f| f.label(:name) end @@ -280,7 +280,7 @@ class FormHelperTest < ActionView::TestCase end def test_label_does_not_generate_for_attribute_when_given_nil - assert_dom_equal('', label(:post, :title, for: nil)) + assert_dom_equal("", label(:post, :title, for: nil)) end def test_label_with_id_attribute_as_symbol @@ -429,7 +429,7 @@ class FormHelperTest < ActionView::TestCase def test_text_field_placeholder_with_locales_and_nested_attributes with_locale :placeholder do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:comments) do |cf| concat cf.text_field(:body, placeholder: true) end @@ -445,7 +445,7 @@ class FormHelperTest < ActionView::TestCase def test_text_field_placeholder_with_locales_fallback_and_nested_attributes with_locale :placeholder do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:tags) do |cf| concat cf.text_field(:value, placeholder: true) end @@ -523,7 +523,7 @@ class FormHelperTest < ActionView::TestCase end def test_text_field_doesnt_change_param_values - object_name = 'post[]' + object_name = "post[]" expected = '' assert_dom_equal expected, text_field(object_name, "title") end @@ -621,19 +621,19 @@ class FormHelperTest < ActionView::TestCase end def test_check_box_checked_if_object_value_includes_checked_value - @post.secret = ['0'] + @post.secret = ["0"] assert_dom_equal( '', check_box("post", "secret") ) - @post.secret = ['1'] + @post.secret = ["1"] assert_dom_equal( '', check_box("post", "secret") ) - @post.secret = Set.new(['1']) + @post.secret = Set.new(["1"]) assert_dom_equal( '', check_box("post", "secret") @@ -882,7 +882,7 @@ class FormHelperTest < ActionView::TestCase def test_text_area_placeholder_with_locales_and_nested_attributes with_locale :placeholder do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:comments) do |cf| concat cf.text_area(:body, placeholder: true) end @@ -898,7 +898,7 @@ class FormHelperTest < ActionView::TestCase def test_text_area_placeholder_with_locales_fallback_and_nested_attributes with_locale :placeholder do - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| f.fields_for(:tags) do |cf| concat cf.text_area(:value, placeholder: true) end @@ -1041,9 +1041,9 @@ class FormHelperTest < ActionView::TestCase end def test_date_field_with_timewithzone_value - previous_time_zone, Time.zone = Time.zone, 'UTC' + previous_time_zone, Time.zone = Time.zone, "UTC" expected = %{} - @post.written_on = Time.zone.parse('2004-06-15 15:30:45') + @post.written_on = Time.zone.parse("2004-06-15 15:30:45") assert_dom_equal(expected, date_field("post", "written_on")) ensure Time.zone = previous_time_zone @@ -1092,9 +1092,9 @@ class FormHelperTest < ActionView::TestCase end def test_time_field_with_timewithzone_value - previous_time_zone, Time.zone = Time.zone, 'UTC' + previous_time_zone, Time.zone = Time.zone, "UTC" expected = %{} - @post.written_on = Time.zone.parse('2004-06-15 01:02:03') + @post.written_on = Time.zone.parse("2004-06-15 01:02:03") assert_dom_equal(expected, time_field("post", "written_on")) ensure Time.zone = previous_time_zone @@ -1149,9 +1149,9 @@ class FormHelperTest < ActionView::TestCase end def test_datetime_field_with_timewithzone_value - previous_time_zone, Time.zone = Time.zone, 'UTC' + previous_time_zone, Time.zone = Time.zone, "UTC" expected = %{} - @post.written_on = Time.zone.parse('2004-06-15 15:30:45') + @post.written_on = Time.zone.parse("2004-06-15 15:30:45") assert_dom_equal(expected, datetime_field("post", "written_on")) ensure Time.zone = previous_time_zone @@ -1211,9 +1211,9 @@ class FormHelperTest < ActionView::TestCase end def test_month_field_with_timewithzone_value - previous_time_zone, Time.zone = Time.zone, 'UTC' + previous_time_zone, Time.zone = Time.zone, "UTC" expected = %{} - @post.written_on = Time.zone.parse('2004-06-15 15:30:45') + @post.written_on = Time.zone.parse("2004-06-15 15:30:45") assert_dom_equal(expected, month_field("post", "written_on")) ensure Time.zone = previous_time_zone @@ -1246,9 +1246,9 @@ class FormHelperTest < ActionView::TestCase end def test_week_field_with_timewithzone_value - previous_time_zone, Time.zone = Time.zone, 'UTC' + previous_time_zone, Time.zone = Time.zone, "UTC" expected = %{} - @post.written_on = Time.zone.parse('2004-06-15 15:30:45') + @post.written_on = Time.zone.parse("2004-06-15 15:30:45") assert_dom_equal(expected, week_field("post", "written_on")) ensure Time.zone = previous_time_zone @@ -1407,26 +1407,26 @@ class FormHelperTest < ActionView::TestCase def test_index_with_nil_id assert_dom_equal( '', - text_field("post", "title", "index" => 5, 'id' => nil) + text_field("post", "title", "index" => 5, "id" => nil) ) assert_dom_equal( %{}, - text_area("post", "body", "index" => 5, 'id' => nil) + text_area("post", "body", "index" => 5, "id" => nil) ) assert_dom_equal( '', - check_box("post", "secret", "index" => 5, 'id' => nil) + check_box("post", "secret", "index" => 5, "id" => nil) ) assert_dom_equal( - text_field("post", "title", "index" => 5, 'id' => nil), + text_field("post", "title", "index" => 5, "id" => nil), text_field("post", "title", index: 5, id: nil) ) assert_dom_equal( - text_area("post", "body", "index" => 5, 'id' => nil), + text_area("post", "body", "index" => 5, "id" => nil), text_area("post", "body", index: 5, id: nil) ) assert_dom_equal( - check_box("post", "secret", "index" => 5, 'id' => nil), + check_box("post", "secret", "index" => 5, "id" => nil), check_box("post", "secret", index: 5, id: nil) ) end @@ -1485,35 +1485,35 @@ class FormHelperTest < ActionView::TestCase def test_form_for_requires_block error = assert_raises(ArgumentError) do - form_for(@post, html: { id: 'create-post' }) + form_for(@post, html: { id: "create-post" }) end assert_equal "Missing block", error.message end def test_form_for_requires_arguments error = assert_raises(ArgumentError) do - form_for(nil, html: { id: 'create-post' }) do + form_for(nil, html: { id: "create-post" }) do end end assert_equal "First argument in form cannot contain nil or be empty", error.message error = assert_raises(ArgumentError) do - form_for([nil, nil], html: { id: 'create-post' }) do + form_for([nil, nil], html: { id: "create-post" }) do end end assert_equal "First argument in form cannot contain nil or be empty", error.message end def test_form_for - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| concat f.label(:title) { "The Title" } concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) - concat f.submit('Create post') - concat f.button('Create post') + concat f.submit("Create post") + concat f.button("Create post") concat f.button { - concat content_tag(:span, 'Create post') + concat content_tag(:span, "Create post") } end @@ -1604,7 +1604,7 @@ class FormHelperTest < ActionView::TestCase post = Post.new def post.active; false; end - form_for(post, namespace: 'foo') do |f| + form_for(post, namespace: "foo") do |f| concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) end @@ -1623,7 +1623,7 @@ class FormHelperTest < ActionView::TestCase post = Post.new def post.active; false; end - form_for(post, index: '1') do |f| + form_for(post, index: "1") do |f| concat f.collection_radio_buttons(:active, [true, false], :to_s, :to_s) end @@ -1722,7 +1722,7 @@ class FormHelperTest < ActionView::TestCase def post.tag_ids; [1]; end collection = [[1, "Tag 1"]] - form_for(post, namespace: 'foo') do |f| + form_for(post, namespace: "foo") do |f| concat f.collection_check_boxes(:tag_ids, collection, :first, :last) end @@ -1740,7 +1740,7 @@ class FormHelperTest < ActionView::TestCase def post.tag_ids; [1]; end collection = [[1, "Tag 1"]] - form_for(post, index: '1') do |f| + form_for(post, index: "1") do |f| concat f.collection_check_boxes(:tag_ids, collection, :first, :last) end @@ -1756,7 +1756,7 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_file_field_generate_multipart Post.send :attr_accessor, :file - form_for(@post, html: { id: 'create-post' }) do |f| + form_for(@post, html: { id: "create-post" }) do |f| concat f.file_field(:file) end @@ -1788,7 +1788,7 @@ class FormHelperTest < ActionView::TestCase concat f.label(:title) end - expected = whole_form("/posts/123.json", "edit_post_123", "edit_post", method: 'patch') do + expected = whole_form("/posts/123.json", "edit_post_123", "edit_post", method: "patch") do "" end @@ -1800,7 +1800,7 @@ class FormHelperTest < ActionView::TestCase form_for(blog_post) do |f| concat f.text_field :title - concat f.submit('Edit post') + concat f.submit("Edit post") end expected = whole_form("/posts/44", "edit_post_44", "edit_post", method: "patch") do @@ -1813,11 +1813,11 @@ class FormHelperTest < ActionView::TestCase def test_form_for_with_symbol_object_name form_for(@post, as: "other_name", html: { id: "create-post" }) do |f| - concat f.label(:title, class: 'post_title') + concat f.label(:title, class: "post_title") concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) - concat f.submit('Create post') + concat f.submit("Create post") end expected = whole_form("/posts/123", "create-post", "edit_other_name", method: "patch") do @@ -1841,13 +1841,13 @@ class FormHelperTest < ActionView::TestCase end end.new - form_for(obj, as: "other_name", url: '/', html: { id: "edit-other-name" }) do |f| + form_for(obj, as: "other_name", url: "/", html: { id: "edit-other-name" }) do |f| assert_raise(NoMethodError) { f.hidden_field(:private_property) } end end def test_form_for_with_method_as_part_of_html_options - form_for(@post, url: '/', html: { id: 'create-post', method: :delete }) do |f| + form_for(@post, url: "/", html: { id: "create-post", method: :delete }) do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -1864,7 +1864,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_method - form_for(@post, url: '/', method: :delete, html: { id: 'create-post' }) do |f| + form_for(@post, url: "/", method: :delete, html: { id: "create-post" }) do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -1895,7 +1895,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_remote - form_for(@post, url: '/', remote: true, html: { id: 'create-post', method: :patch }) do |f| + form_for(@post, url: "/", remote: true, html: { id: "create-post", method: :patch }) do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -1936,7 +1936,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_remote_in_html - form_for(@post, url: '/', html: { remote: true, id: 'create-post', method: :patch }) do |f| + form_for(@post, url: "/", html: { remote: true, id: "create-post", method: :patch }) do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -1973,7 +1973,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_without_object - form_for(:post, html: { id: 'create-post' }) do |f| + form_for(:post, html: { id: "create-post" }) do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) @@ -1997,7 +1997,7 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" + "" + "" + @@ -2015,7 +2015,7 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" + "" + "" + @@ -2027,12 +2027,12 @@ class FormHelperTest < ActionView::TestCase def test_form_for_label_error_wrapping form_for(@post) do |f| - concat f.label(:author_name, class: 'label') + concat f.label(:author_name, class: "label") concat f.text_field(:author_name) - concat f.submit('Create post') + concat f.submit("Create post") end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" + "
" + "" @@ -2045,12 +2045,12 @@ class FormHelperTest < ActionView::TestCase post = remove_instance_variable :@post form_for(post) do |f| - concat f.label(:author_name, class: 'label') + concat f.label(:author_name, class: "label") concat f.text_field(:author_name) - concat f.submit('Create post') + concat f.submit("Create post") end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" + "
" + "" @@ -2061,11 +2061,11 @@ class FormHelperTest < ActionView::TestCase def test_form_for_label_error_wrapping_block_and_non_block_versions form_for(@post) do |f| - concat f.label(:author_name, 'Name', class: 'label') - concat f.label(:author_name, class: 'label') { 'Name' } + concat f.label(:author_name, "Name", class: "label") + concat f.label(:author_name, class: "label") { "Name" } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" + "
" end @@ -2074,13 +2074,13 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_namespace - form_for(@post, namespace: 'namespace') do |f| + form_for(@post, namespace: "namespace") do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.check_box(:secret) end - expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do "" + "" + "" + @@ -2091,20 +2091,20 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_namespace_with_date_select - form_for(@post, namespace: 'namespace') do |f| + form_for(@post, namespace: "namespace") do |f| concat f.date_select(:written_on) end - assert_select 'select#namespace_post_written_on_1i' + assert_select "select#namespace_post_written_on_1i" end def test_form_for_with_namespace_with_label - form_for(@post, namespace: 'namespace') do |f| + form_for(@post, namespace: "namespace") do |f| concat f.label(:title) concat f.text_field(:title) end - expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do "" + "" end @@ -2113,11 +2113,11 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_namespace_and_as_option - form_for(@post, namespace: 'namespace', as: 'custom_name') do |f| + form_for(@post, namespace: "namespace", as: "custom_name") do |f| concat f.text_field(:title) end - expected = whole_form('/posts/123', 'namespace_edit_custom_name', 'edit_custom_name', method: 'patch') do + expected = whole_form("/posts/123", "namespace_edit_custom_name", "edit_custom_name", method: "patch") do "" end @@ -2125,24 +2125,24 @@ class FormHelperTest < ActionView::TestCase end def test_two_form_for_with_namespace - form_for(@post, namespace: 'namespace_1') do |f| + form_for(@post, namespace: "namespace_1") do |f| concat f.label(:title) concat f.text_field(:title) end - expected_1 = whole_form('/posts/123', 'namespace_1_edit_post_123', 'edit_post', method: 'patch') do + expected_1 = whole_form("/posts/123", "namespace_1_edit_post_123", "edit_post", method: "patch") do "" + "" end assert_dom_equal expected_1, output_buffer - form_for(@post, namespace: 'namespace_2') do |f| + form_for(@post, namespace: "namespace_2") do |f| concat f.label(:title) concat f.text_field(:title) end - expected_2 = whole_form('/posts/123', 'namespace_2_edit_post_123', 'edit_post', method: 'patch') do + expected_2 = whole_form("/posts/123", "namespace_2_edit_post_123", "edit_post", method: "patch") do "" + "" end @@ -2151,8 +2151,8 @@ class FormHelperTest < ActionView::TestCase end def test_fields_for_with_namespace - @comment.body = 'Hello World' - form_for(@post, namespace: 'namespace') do |f| + @comment.body = "Hello World" + form_for(@post, namespace: "namespace") do |f| concat f.text_field(:title) concat f.text_area(:body) concat f.fields_for(@comment) { |c| @@ -2160,7 +2160,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'namespace_edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "namespace_edit_post_123", "edit_post", method: "patch") do "" + "" + "" @@ -2177,7 +2177,7 @@ class FormHelperTest < ActionView::TestCase concat f.submit end - expected = whole_form('/posts', 'new_post', 'new_post') do + expected = whole_form("/posts", "new_post", "new_post") do "" end @@ -2192,7 +2192,7 @@ class FormHelperTest < ActionView::TestCase concat f.submit end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -2220,7 +2220,7 @@ class FormHelperTest < ActionView::TestCase concat f.submit end - expected = whole_form('/posts/123', 'edit_another_post', 'edit_another_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_another_post", "edit_another_post", method: "patch") do "" end @@ -2229,14 +2229,14 @@ class FormHelperTest < ActionView::TestCase end def test_nested_fields_for - @comment.body = 'Hello World' + @comment.body = "Hello World" form_for(@post) do |f| concat f.fields_for(@comment) { |c| concat c.text_field(:body) } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -2246,10 +2246,10 @@ class FormHelperTest < ActionView::TestCase def test_deep_nested_fields_for @comment.save form_for(:posts) do |f| - f.fields_for('post[]', @post) do |f2| + f.fields_for("post[]", @post) do |f2| f2.text_field(:id) @post.comments.each do |comment| - concat f2.fields_for('comment[]', comment) { |c| + concat f2.fields_for("comment[]", comment) { |c| concat c.text_field(:name) } end @@ -2265,14 +2265,14 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_nested_collections - form_for(@post, as: 'post[]') do |f| + form_for(@post, as: "post[]") do |f| concat f.text_field(:title) - concat f.fields_for('comment[]', @comment) { |c| + concat f.fields_for("comment[]", @comment) { |c| concat c.text_field(:name) } end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" + "" end @@ -2283,12 +2283,12 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_for_with_index_and_parent_fields form_for(@post, index: 1) do |c| concat c.text_field(:title) - concat c.fields_for('comment', @comment, index: 1) { |r| + concat c.fields_for("comment", @comment, index: 1) { |r| concat r.text_field(:name) } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" + "" end @@ -2303,7 +2303,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -2317,7 +2317,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -2331,7 +2331,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" end @@ -2345,7 +2345,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -2359,7 +2359,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" end @@ -2379,9 +2379,9 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post[]', 'edit_post[]', method: 'patch') do + expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do "" - end + whole_form('/posts/123', 'edit_post', 'edit_post', method: 'patch') do + end + whole_form("/posts/123", "edit_post", "edit_post", method: "patch") do "" end @@ -2398,7 +2398,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2425,7 +2425,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' @@ -2444,7 +2444,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' @@ -2463,7 +2463,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2481,7 +2481,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2499,7 +2499,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' @@ -2519,7 +2519,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' @@ -2540,7 +2540,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2567,7 +2567,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2594,7 +2594,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2620,7 +2620,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2643,7 +2643,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2667,7 +2667,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2690,7 +2690,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' @@ -2711,7 +2711,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2729,7 +2729,7 @@ class FormHelperTest < ActionView::TestCase end end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' end @@ -2746,7 +2746,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2767,7 +2767,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2781,7 +2781,7 @@ class FormHelperTest < ActionView::TestCase def test_nested_fields_label_translation_with_more_than_10_records @post.comments = Array.new(11) { |id| Comment.new(id + 1) } - params = 11.times.map { ['post.comments.body', default: [:"comment.body", ''], scope: "helpers.label"] } + params = 11.times.map { ["post.comments.body", default: [:"comment.body", ""], scope: "helpers.label"] } assert_called_with(I18n, :t, params, returns: "Write body here") do form_for(@post) do |f| f.fields_for(:comments) do |cf| @@ -2802,7 +2802,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2825,7 +2825,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2840,12 +2840,12 @@ class FormHelperTest < ActionView::TestCase @post.comments = [] form_for(@post) do |f| - concat f.fields_for(:comments, Comment.new(321), child_index: 'abc') { |cf| + concat f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf| concat cf.text_field(:name) } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2857,12 +2857,12 @@ class FormHelperTest < ActionView::TestCase @post.comments = [] form_for(@post) do |f| - concat f.fields_for(:comments, Comment.new(321), child_index: -> { 'abc' } ) { |cf| + concat f.fields_for(:comments, Comment.new(321), child_index: -> { "abc" } ) { |cf| concat cf.text_field(:name) } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2880,12 +2880,12 @@ class FormHelperTest < ActionView::TestCase @post.comments = FakeAssociationProxy.new form_for(@post) do |f| - concat f.fields_for(:comments, Comment.new(321), child_index: 'abc') { |cf| + concat f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf| concat cf.text_field(:name) } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' end @@ -2937,8 +2937,8 @@ class FormHelperTest < ActionView::TestCase @post.comments = [] form_for(@post) do |f| - f.fields_for(:comments, Comment.new(321), child_index: 'abc') { |cf| - assert_equal cf.index, 'abc' + f.fields_for(:comments, Comment.new(321), child_index: "abc") { |cf| + assert_equal cf.index, "abc" } end end @@ -2963,7 +2963,7 @@ class FormHelperTest < ActionView::TestCase concat trf.text_field(:value) } } - concat f.fields_for('tags', @post.tags[1]) { |tf| + concat f.fields_for("tags", @post.tags[1]) { |tf| concat tf.text_field(:value) concat tf.fields_for(:relevances, TagRelevance.new(31415)) { |trf| concat trf.text_field(:value) @@ -2971,7 +2971,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' + '' + '' + @@ -2998,7 +2998,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do '' end @@ -3128,7 +3128,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_and_fields_for - form_for(@post, as: :post, html: { id: 'create-post' }) do |post_form| + form_for(@post, as: :post, html: { id: "create-post" }) do |post_form| concat post_form.text_field(:title) concat post_form.text_area(:body) @@ -3137,7 +3137,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'create-post', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do "" + "" + "" + @@ -3148,7 +3148,7 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_and_fields_for_with_object - form_for(@post, as: :post, html: { id: 'create-post' }) do |post_form| + form_for(@post, as: :post, html: { id: "create-post" }) do |post_form| concat post_form.text_field(:title) concat post_form.text_area(:body) @@ -3157,7 +3157,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'create-post', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "create-post", "edit_post", method: "patch") do "" + "" + "" @@ -3173,7 +3173,7 @@ class FormHelperTest < ActionView::TestCase } end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "" end @@ -3197,7 +3197,7 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" + "
" + "
" @@ -3216,7 +3216,7 @@ class FormHelperTest < ActionView::TestCase concat f.check_box(:secret) end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" + "
" + "
" @@ -3235,7 +3235,7 @@ class FormHelperTest < ActionView::TestCase concat f.text_field(:title) end - expected = whole_form('/posts/123', 'edit_post_123', 'edit_post', method: 'patch') do + expected = whole_form("/posts/123", "edit_post_123", "edit_post", method: "patch") do "
" end @@ -3289,7 +3289,7 @@ class FormHelperTest < ActionView::TestCase form_for(@post, builder: LabelledFormBuilder) do |f| f.fields_for(:comments, Comment.new) do |nested_fields| klass = nested_fields.class - '' + "" end end @@ -3300,9 +3300,9 @@ class FormHelperTest < ActionView::TestCase klass = nil form_for(@post, builder: LabelledFormBuilder) do |f| - f.fields_for(:comments, Comment.new, index: 'foo') do |nested_fields| + f.fields_for(:comments, Comment.new, index: "foo") do |nested_fields| klass = nested_fields.class - '' + "" end end @@ -3314,10 +3314,10 @@ class FormHelperTest < ActionView::TestCase form_for(@post, builder: LabelledFormBuilder) do |f| path = f.to_partial_path - '' + "" end - assert_equal 'labelled_form', path + assert_equal "labelled_form", path end class LabelledFormBuilderSubclass < LabelledFormBuilder; end @@ -3328,7 +3328,7 @@ class FormHelperTest < ActionView::TestCase form_for(@post, builder: LabelledFormBuilder) do |f| f.fields_for(:comments, Comment.new, builder: LabelledFormBuilderSubclass) do |nested_fields| klass = nested_fields.class - '' + "" end end @@ -3336,23 +3336,23 @@ class FormHelperTest < ActionView::TestCase end def test_form_for_with_html_options_adds_options_to_form_tag - form_for(@post, html: { id: 'some_form', class: 'some_class', multipart: true }) do |f| end + form_for(@post, html: { id: "some_form", class: "some_class", multipart: true }) do |f| end expected = whole_form("/posts/123", "some_form", "some_class", method: "patch", multipart: "multipart/form-data") assert_dom_equal expected, output_buffer end def test_form_for_with_string_url_option - form_for(@post, url: 'http://www.otherdomain.com') do |f| end + form_for(@post, url: "http://www.otherdomain.com") do |f| end assert_dom_equal whole_form("http://www.otherdomain.com", "edit_post_123", "edit_post", method: "patch"), output_buffer end def test_form_for_with_hash_url_option - form_for(@post, url: { controller: 'controller', action: 'action' }) do |f| end + form_for(@post, url: { controller: "controller", action: "action" }) do |f| end - assert_equal 'controller', @url_for_options[:controller] - assert_equal 'action', @url_for_options[:action] + assert_equal "controller", @url_for_options[:controller] + assert_equal "action", @url_for_options[:action] end def test_form_for_with_record_url_option @@ -3444,7 +3444,7 @@ class FormHelperTest < ActionView::TestCase end form_for(@post, builder: builder_class) { } - assert_equal 1, initialization_count, 'form builder instantiated more than once' + assert_equal 1, initialization_count, "form builder instantiated more than once" end protected @@ -3455,7 +3455,7 @@ class FormHelperTest < ActionView::TestCase if options.fetch(:enforce_utf8, true) txt = %{} else - txt = '' + txt = "" end if method && !%w(get post).include?(method.to_s) diff --git a/actionview/test/template/form_options_helper_i18n_test.rb b/actionview/test/template/form_options_helper_i18n_test.rb index 26ede09a5f..dae0fd15f1 100644 --- a/actionview/test/template/form_options_helper_i18n_test.rb +++ b/actionview/test/template/form_options_helper_i18n_test.rb @@ -1,10 +1,10 @@ -require 'abstract_unit' +require "abstract_unit" class FormOptionsHelperI18nTests < ActionView::TestCase tests ActionView::Helpers::FormOptionsHelper def setup - @prompt_message = 'Select!' + @prompt_message = "Select!" I18n.backend.send(:init_translations) I18n.backend.store_translations :en, :helpers => { :select => { :prompt => @prompt_message } } end @@ -14,15 +14,15 @@ class FormOptionsHelperI18nTests < ActionView::TestCase end def test_select_with_prompt_true_translates_prompt_message - assert_called_with(I18n, :translate, ['helpers.select.prompt', { :default => 'Please select' }]) do - select('post', 'category', [], :prompt => true) + assert_called_with(I18n, :translate, ["helpers.select.prompt", { :default => "Please select" }]) do + select("post", "category", [], :prompt => true) end end def test_select_with_translated_prompt assert_dom_equal( %Q(), - select('post', 'category', [], :prompt => true) + select("post", "category", [], :prompt => true) ) end end diff --git a/actionview/test/template/form_options_helper_test.rb b/actionview/test/template/form_options_helper_test.rb index a85f2da264..3a2a2cbde2 100644 --- a/actionview/test/template/form_options_helper_test.rb +++ b/actionview/test/template/form_options_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class Map < Hash def category @@ -10,11 +10,11 @@ class FormOptionsHelperTest < ActionView::TestCase tests ActionView::Helpers::FormOptionsHelper silence_warnings do - Post = Struct.new('Post', :title, :author_name, :body, :secret, :written_on, :category, :origin, :allow_comments) - Continent = Struct.new('Continent', :continent_name, :countries) - Country = Struct.new('Country', :country_id, :country_name) - Firm = Struct.new('Firm', :time_zone) - Album = Struct.new('Album', :id, :title, :genre) + Post = Struct.new("Post", :title, :author_name, :body, :secret, :written_on, :category, :origin, :allow_comments) + Continent = Struct.new("Continent", :continent_name, :countries) + Country = Struct.new("Country", :country_id, :country_name) + Firm = Struct.new("Firm", :time_zone) + Album = Struct.new("Album", :id, :title, :genre) end module FakeZones @@ -75,7 +75,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_collection_options_with_proc_for_selected assert_dom_equal( "\n\n", - options_from_collection_for_select(dummy_posts, "author_name", "title", lambda{|p| p.author_name == 'Babe' }) + options_from_collection_for_select(dummy_posts, "author_name", "title", lambda{|p| p.author_name == "Babe" }) ) end @@ -124,7 +124,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_collection_options_with_element_attributes assert_dom_equal( "", - options_from_collection_for_select([[ "USA", "USA", { :class => 'bold' } ]], :first, :second) + options_from_collection_for_select([[ "USA", "USA", { :class => "bold" } ]], :first, :second) ) end @@ -147,8 +147,8 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "\n", options_for_select([ - ['Richard Bandler', 1, { type: 'Coach', selected: 'selected' }], - ['Richard Bandler', 1, { type: 'Coachee' }] + ["Richard Bandler", 1, { type: "Coach", selected: "selected" }], + ["Richard Bandler", 1, { type: "Coachee" }] ]) ) end @@ -157,8 +157,8 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "\n", options_for_select([ - ['Richard Bandler', 1, { type: 'Coach', disabled: 'disabled' }], - ['Richard Bandler', 1, { type: 'Coachee' }] + ["Richard Bandler", 1, { type: "Coach", disabled: "disabled" }], + ["Richard Bandler", 1, { type: "Coachee" }] ]) ) end @@ -336,7 +336,7 @@ class FormOptionsHelperTest < ActionView::TestCase "\n\n", grouped_options_for_select([ ["North America", - [['United States','US'],"Canada"]], + [["United States","US"],"Canada"]], ["Europe", [["Great Britain","GB"], "Germany"]] ]) @@ -347,8 +347,8 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "\n\n", grouped_options_for_select([ - ["North America", [['United States','US'],"Canada"], :data => { :foo => 'bar' }], - ["Europe", [["Great Britain","GB"], "Germany"], :disabled => 'disabled'] + ["North America", [["United States","US"],"Canada"], :data => { :foo => "bar" }], + ["Europe", [["Great Britain","GB"], "Germany"], :disabled => "disabled"] ]) ) end @@ -357,7 +357,7 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "\n\n", - grouped_options_for_select([['US',"Canada"] , ["GB", "Germany"]], nil, divider: "----------") + grouped_options_for_select([["US","Canada"] , ["GB", "Germany"]], nil, divider: "----------") ) end @@ -382,13 +382,13 @@ class FormOptionsHelperTest < ActionView::TestCase def test_grouped_options_for_select_with_prompt_returns_html_escaped_string assert_dom_equal( "\n", - grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, prompt: '')) + grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]], nil, prompt: "")) end def test_optgroups_with_with_options_with_hash assert_dom_equal( "\n\n", - grouped_options_for_select({'North America' => ['United States','Canada'], 'Europe' => ['Denmark','Germany']}) + grouped_options_for_select({"North America" => ["United States","Canada"], "Europe" => ["Denmark","Germany"]}) ) end @@ -591,7 +591,7 @@ class FormOptionsHelperTest < ActionView::TestCase options = raw("") output_buffer = fields_for :post, @post do |f| - concat f.select(:category, options, :prompt => 'The prompt') + concat f.select(:category, options, :prompt => "The prompt") end assert_dom_equal( @@ -645,7 +645,7 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_select_with_multiple_and_with_explicit_name_ending_with_brackets - output_buffer = select(:post, :category, [], {include_hidden: false}, multiple: true, name: 'post[category][]') + output_buffer = select(:post, :category, [], {include_hidden: false}, multiple: true, name: "post[category][]") assert_dom_equal( "", output_buffer @@ -672,7 +672,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_select_with_include_blank_false_and_required @post = Post.new @post.category = "" - e = assert_raises(ArgumentError) { select("post", "category", %w( abe hest), { include_blank: false }, required: 'required') } + e = assert_raises(ArgumentError) { select("post", "category", %w( abe hest), { include_blank: false }, required: "required") } assert_match(/include_blank cannot be false for a required field./, e.message) end @@ -681,7 +681,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest), :include_blank => 'None') + select("post", "category", %w( abe hest), :include_blank => "None") ) end @@ -690,7 +690,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest), :include_blank => '') + select("post", "category", %w( abe hest), :include_blank => "") ) end @@ -717,7 +717,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest), :prompt => 'The prompt') + select("post", "category", %w( abe hest), :prompt => "The prompt") ) end @@ -725,7 +725,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post = Post.new assert_dom_equal( "", - select("post", "category", %w( abe hest), :prompt => '') + select("post", "category", %w( abe hest), :prompt => "") ) end @@ -752,7 +752,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", [], { prompt: true, include_blank: true }, { class: 'disabled', disabled: true }) + select("post", "category", [], { prompt: true, include_blank: true }, { class: "disabled", disabled: true }) ) end @@ -830,7 +830,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest ), :selected => 'abe') + select("post", "category", %w( abe hest ), :selected => "abe") ) end @@ -849,7 +849,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_select_escapes_options assert_dom_equal( '', - select('post', 'title', '') + select("post", "title", "") ) end @@ -867,7 +867,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest ), :disabled => 'hest') + select("post", "category", %w( abe hest ), :disabled => "hest") ) end @@ -875,7 +875,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post = Post.new assert_dom_equal( "", - select("post", "locale", %w( en ru ), :selected => 'ru') + select("post", "locale", %w( en ru ), :selected => "ru") ) end @@ -883,7 +883,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post = Post.new assert_dom_equal( "", - select("post", "category", %w( one two ), :selected => 'two', :prompt => true) + select("post", "category", %w( one two ), :selected => "two", :prompt => true) ) end @@ -892,7 +892,7 @@ class FormOptionsHelperTest < ActionView::TestCase @post.category = "" assert_dom_equal( "", - select("post", "category", %w( abe hest ), :disabled => ['hest', 'abe']) + select("post", "category", %w( abe hest ), :disabled => ["hest", "abe"]) ) end @@ -974,7 +974,7 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => 'No Selection' }, "style" => "width: 200px") + collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => "No Selection" }, "style" => "width: 200px") ) end @@ -988,7 +988,7 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true }, :multiple => true) # Shouldn't suffix custom name with []. - assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true, :name => 'post[author_name][]' }, :multiple => true) + assert_dom_equal expected, collection_select("post", "author_name", dummy_posts, "author_name", "author_name", { :include_blank => true, :name => "post[author_name][]" }, :multiple => true) end def test_collection_select_with_blank_and_selected @@ -1007,7 +1007,7 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( "", - collection_select("post", "author_name", dummy_posts, "author_name", "author_name", :disabled => 'Cabe') + collection_select("post", "author_name", dummy_posts, "author_name", "author_name", :disabled => "Cabe") ) end @@ -1116,7 +1116,7 @@ class FormOptionsHelperTest < ActionView::TestCase def test_time_zone_select_with_blank_as_string @firm = Firm.new("D") - html = time_zone_select("firm", "time_zone", nil, :include_blank => 'No Zone') + html = time_zone_select("firm", "time_zone", nil, :include_blank => "No Zone") assert_dom_equal "" + "\n" + "\n" + @@ -1175,7 +1175,7 @@ class FormOptionsHelperTest < ActionView::TestCase "", html assert_dom_equal html, time_zone_select("firm", "time_zone", nil, - { :include_blank => 'No Zone' }, :style => "color: red") + { :include_blank => "No Zone" }, :style => "color: red") end def test_time_zone_select_with_priority_zones @@ -1237,7 +1237,7 @@ class FormOptionsHelperTest < ActionView::TestCase @firm = Firm.new() @firm.time_zone = nil - html = time_zone_select( "firm", "time_zone", nil, :default => 'B' ) + html = time_zone_select( "firm", "time_zone", nil, :default => "B" ) assert_dom_equal "" + "\n" + "\n" + @@ -1265,35 +1265,35 @@ class FormOptionsHelperTest < ActionView::TestCase def test_options_for_select_with_element_attributes assert_dom_equal( "\n\n\n", - options_for_select([ [ "", { :class => 'bold' } ], [ "USA", { :onclick => "alert('Hello World');" } ], [ "Sweden" ], "Germany" ]) + options_for_select([ [ "", { :class => "bold" } ], [ "USA", { :onclick => "alert('Hello World');" } ], [ "Sweden" ], "Germany" ]) ) end def test_options_for_select_with_data_element assert_dom_equal( "", - options_for_select([ [ "", { :data => { :test => 'bold' } } ] ]) + options_for_select([ [ "", { :data => { :test => "bold" } } ] ]) ) end def test_options_for_select_with_data_element_with_special_characters assert_dom_equal( "", - options_for_select([ [ "", { :data => { :test => '' } } ] ]) + options_for_select([ [ "", { :data => { :test => "" } } ] ]) ) end def test_options_for_select_with_element_attributes_and_selection assert_dom_equal( "\n\n", - options_for_select([ "", [ "USA", { :class => 'bold' } ], "Sweden" ], "USA") + options_for_select([ "", [ "USA", { :class => "bold" } ], "Sweden" ], "USA") ) end def test_options_for_select_with_element_attributes_and_selection_array assert_dom_equal( "\n\n", - options_for_select([ "", [ "USA", { :class => 'bold' } ], "Sweden" ], [ "USA", "Sweden" ]) + options_for_select([ "", [ "USA", { :class => "bold" } ], "Sweden" ], [ "USA", "Sweden" ]) ) end @@ -1305,46 +1305,46 @@ class FormOptionsHelperTest < ActionView::TestCase end def test_option_html_attributes_with_no_array_element - assert_equal({}, option_html_attributes('foo')) + assert_equal({}, option_html_attributes("foo")) end def test_option_html_attributes_without_hash - assert_equal({}, option_html_attributes([ 'foo', 'bar' ])) + assert_equal({}, option_html_attributes([ "foo", "bar" ])) end def test_option_html_attributes_with_single_element_hash assert_equal( - {:class => 'fancy'}, - option_html_attributes([ 'foo', 'bar', { :class => 'fancy' } ]) + {:class => "fancy"}, + option_html_attributes([ "foo", "bar", { :class => "fancy" } ]) ) end def test_option_html_attributes_with_multiple_element_hash assert_equal( - {:class => 'fancy', 'onclick' => "alert('Hello World');"}, - option_html_attributes([ 'foo', 'bar', { :class => 'fancy', 'onclick' => "alert('Hello World');" } ]) + {:class => "fancy", "onclick" => "alert('Hello World');"}, + option_html_attributes([ "foo", "bar", { :class => "fancy", "onclick" => "alert('Hello World');" } ]) ) end def test_option_html_attributes_with_multiple_hashes assert_equal( - {:class => 'fancy', 'onclick' => "alert('Hello World');"}, - option_html_attributes([ 'foo', 'bar', { :class => 'fancy' }, { 'onclick' => "alert('Hello World');" } ]) + {:class => "fancy", "onclick" => "alert('Hello World');"}, + option_html_attributes([ "foo", "bar", { :class => "fancy" }, { "onclick" => "alert('Hello World');" } ]) ) end def test_option_html_attributes_with_multiple_hashes_does_not_modify_them - options1 = { class: 'fancy' } + options1 = { class: "fancy" } options2 = { onclick: "alert('Hello World');" } - option_html_attributes([ 'foo', 'bar', options1, options2 ]) + option_html_attributes([ "foo", "bar", options1, options2 ]) - assert_equal({ class: 'fancy' }, options1) + assert_equal({ class: "fancy" }, options1) assert_equal({ onclick: "alert('Hello World');" }, options2) end def test_grouped_collection_select @post = Post.new - @post.origin = 'dk' + @post.origin = "dk" assert_dom_equal( %Q{}, @@ -1357,7 +1357,7 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( %Q{}, - grouped_collection_select("post", "origin", dummy_continents, :countries, :continent_name, :country_id, :country_name, :selected => 'dk') + grouped_collection_select("post", "origin", dummy_continents, :countries, :continent_name, :country_id, :country_name, :selected => "dk") ) end @@ -1366,13 +1366,13 @@ class FormOptionsHelperTest < ActionView::TestCase assert_dom_equal( %Q{}, - grouped_collection_select("post", "origin", dummy_continents, :countries, :continent_name, :country_id, :country_name, :disabled => 'dk') + grouped_collection_select("post", "origin", dummy_continents, :countries, :continent_name, :country_id, :country_name, :disabled => "dk") ) end def test_grouped_collection_select_under_fields_for @post = Post.new - @post.origin = 'dk' + @post.origin = "dk" output_buffer = fields_for :post, @post do |f| concat f.grouped_collection_select("origin", dummy_continents, :countries, :continent_name, :country_id, :country_name) diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb index 4fdca4976f..5b5d34b178 100644 --- a/actionview/test/template/form_tag_helper_test.rb +++ b/actionview/test/template/form_tag_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class FormTagHelperTest < ActionView::TestCase include RenderERBUtils @@ -14,7 +14,7 @@ class FormTagHelperTest < ActionView::TestCase method = options[:method] enforce_utf8 = options.fetch(:enforce_utf8, true) - ''.tap do |txt| + "".tap do |txt| if enforce_utf8 txt << %{} end @@ -78,7 +78,7 @@ class FormTagHelperTest < ActionView::TestCase def test_check_box_tag_id_sanitized label_elem = root_elem(check_box_tag("project[2][admin]")) - assert_match VALID_HTML_ID, label_elem['id'] + assert_match VALID_HTML_ID, label_elem["id"] end def test_form_tag @@ -88,7 +88,7 @@ class FormTagHelperTest < ActionView::TestCase end def test_form_tag_multipart - actual = form_tag({}, { 'multipart' => true }) + actual = form_tag({}, { "multipart" => true }) expected = whole_form("http://www.example.com", :enctype => true) assert_dom_equal expected, actual end @@ -165,7 +165,7 @@ class FormTagHelperTest < ActionView::TestCase def test_hidden_field_tag_id_sanitized input_elem = root_elem(hidden_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] + assert_match VALID_HTML_ID, input_elem["id"] end def test_file_field_tag @@ -183,7 +183,7 @@ class FormTagHelperTest < ActionView::TestCase end def test_multiple_field_tags_with_same_options - options = {class: 'important'} + options = {class: "important"} assert_dom_equal %(), file_field_tag("title", options) assert_dom_equal %(), password_field_tag("title", "Hello!", options) assert_dom_equal %(), text_field_tag("title", "Hello!", options) @@ -210,7 +210,7 @@ class FormTagHelperTest < ActionView::TestCase expected = %() assert_dom_equal expected, actual - actual = radio_button_tag('ctrlname', 'apache2.2') + actual = radio_button_tag("ctrlname", "apache2.2") expected = %() assert_dom_equal expected, actual end @@ -235,7 +235,7 @@ class FormTagHelperTest < ActionView::TestCase def test_select_tag_id_sanitized input_elem = root_elem(select_tag("project[1]people", "")) - assert_match VALID_HTML_ID, input_elem['id'] + assert_match VALID_HTML_ID, input_elem["id"] end def test_select_tag_with_include_blank @@ -251,7 +251,7 @@ class FormTagHelperTest < ActionView::TestCase end def test_select_tag_with_include_blank_string - actual = select_tag "places", raw(""), include_blank: 'Choose' + actual = select_tag "places", raw(""), include_blank: "Choose" expected = %() assert_dom_equal expected, actual end @@ -306,7 +306,7 @@ class FormTagHelperTest < ActionView::TestCase def test_text_area_tag_id_sanitized input_elem = root_elem(text_area_tag("item[][description]")) - assert_match VALID_HTML_ID, input_elem['id'] + assert_match VALID_HTML_ID, input_elem["id"] end def test_text_area_tag_escape_content @@ -370,7 +370,7 @@ class FormTagHelperTest < ActionView::TestCase end def test_text_field_tag_with_placeholder_option - actual = text_field_tag "title", "Hello!", placeholder: 'Enter search term...' + actual = text_field_tag "title", "Hello!", placeholder: "Enter search term..." expected = %() assert_dom_equal expected, actual end @@ -383,7 +383,7 @@ class FormTagHelperTest < ActionView::TestCase def test_text_field_tag_id_sanitized input_elem = root_elem(text_field_tag("item[][title]")) - assert_match VALID_HTML_ID, input_elem['id'] + assert_match VALID_HTML_ID, input_elem["id"] end def test_label_tag_without_text @@ -412,11 +412,11 @@ class FormTagHelperTest < ActionView::TestCase def test_label_tag_id_sanitized label_elem = root_elem(label_tag("item[title]")) - assert_match VALID_HTML_ID, label_elem['for'] + assert_match VALID_HTML_ID, label_elem["for"] end def test_label_tag_with_block - assert_dom_equal('', label_tag { "Blocked" }) + assert_dom_equal("", label_tag { "Blocked" }) end def test_label_tag_with_block_and_argument @@ -430,7 +430,7 @@ class FormTagHelperTest < ActionView::TestCase end def test_boolean_options - assert_dom_equal %(), check_box_tag("admin", 1, true, 'disabled' => true, :readonly => "yes") + assert_dom_equal %(), check_box_tag("admin", 1, true, "disabled" => true, :readonly => "yes") assert_dom_equal %(), check_box_tag("admin", 1, true, :disabled => false, :readonly => nil) assert_dom_equal %(), tag(:input, :type => "checkbox", :checked => false) assert_dom_equal %(), select_tag("people", raw(""), :multiple => true) @@ -561,16 +561,16 @@ class FormTagHelperTest < ActionView::TestCase end def test_button_tag_with_block - assert_dom_equal('', button_tag { 'Content' }) + assert_dom_equal('', button_tag { "Content" }) end def test_button_tag_with_block_and_options - output = button_tag(:name => 'temptation', :type => 'button') { content_tag(:strong, 'Do not press me') } + output = button_tag(:name => "temptation", :type => "button") { content_tag(:strong, "Do not press me") } assert_dom_equal('', output) end def test_button_tag_defaults_with_block_and_options - output = button_tag(:name => 'temptation', :value => 'within') { content_tag(:strong, 'Do not press me') } + output = button_tag(:name => "temptation", :value => "within") { content_tag(:strong, "Do not press me") } assert_dom_equal('', output) end diff --git a/actionview/test/template/html_test.rb b/actionview/test/template/html_test.rb index 549c12c88c..60f4b0aee6 100644 --- a/actionview/test/template/html_test.rb +++ b/actionview/test/template/html_test.rb @@ -1,17 +1,17 @@ -require 'abstract_unit' +require "abstract_unit" class HTMLTest < ActiveSupport::TestCase - test 'formats returns symbol for recognized MIME type' do - assert_equal [:html], ActionView::Template::HTML.new('', :html).formats + test "formats returns symbol for recognized MIME type" do + assert_equal [:html], ActionView::Template::HTML.new("", :html).formats end - test 'formats returns string for recognized MIME type when MIME does not have symbol' do + test "formats returns string for recognized MIME type when MIME does not have symbol" do foo = Mime::Type.lookup("foo") assert_nil foo.to_sym - assert_equal ['foo'], ActionView::Template::HTML.new('', foo).formats + assert_equal ["foo"], ActionView::Template::HTML.new("", foo).formats end - test 'formats returns string for unknown MIME type' do - assert_equal ['foo'], ActionView::Template::HTML.new('', 'foo').formats + test "formats returns string for unknown MIME type" do + assert_equal ["foo"], ActionView::Template::HTML.new("", "foo").formats end end diff --git a/actionview/test/template/javascript_helper_test.rb b/actionview/test/template/javascript_helper_test.rb index 9f1535ef53..01ebc8cae1 100644 --- a/actionview/test/template/javascript_helper_test.rb +++ b/actionview/test/template/javascript_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class JavaScriptHelperTest < ActionView::TestCase tests ActionView::Helpers::JavaScriptHelper @@ -16,7 +16,7 @@ class JavaScriptHelperTest < ActionView::TestCase end def test_escape_javascript - assert_equal '', escape_javascript(nil) + assert_equal "", escape_javascript(nil) assert_equal %(This \\"thing\\" is really\\n netos\\'), escape_javascript(%(This "thing" is really\n netos')) assert_equal %(backslash\\\\test), escape_javascript( %(backslash\\test) ) assert_equal %(dont <\\/close> tags), escape_javascript(%(dont tags)) @@ -36,19 +36,19 @@ class JavaScriptHelperTest < ActionView::TestCase end def test_javascript_tag - self.output_buffer = 'foo' + self.output_buffer = "foo" assert_dom_equal "", javascript_tag("alert('hello')") - assert_equal 'foo', output_buffer, 'javascript_tag without a block should not concat to output_buffer' + assert_equal "foo", output_buffer, "javascript_tag without a block should not concat to output_buffer" end # Setting the :extname option will control what extension (if any) is appended to the url for assets def test_javascript_include_tag - assert_dom_equal "", javascript_include_tag('/foo') - assert_dom_equal "", javascript_include_tag('/foo', extname: false ) - assert_dom_equal "", javascript_include_tag('/foo', extname: '.bar' ) + assert_dom_equal "", javascript_include_tag("/foo") + assert_dom_equal "", javascript_include_tag("/foo", extname: false ) + assert_dom_equal "", javascript_include_tag("/foo", extname: ".bar" ) end def test_javascript_tag_with_options diff --git a/actionview/test/template/log_subscriber_test.rb b/actionview/test/template/log_subscriber_test.rb index 7683444bf0..f864999a8e 100644 --- a/actionview/test/template/log_subscriber_test.rb +++ b/actionview/test/template/log_subscriber_test.rb @@ -116,10 +116,10 @@ class AVLogSubscriberTest < ActiveSupport::TestCase def test_render_collection_with_cached_set Rails.stub(:root, File.expand_path(FIXTURE_LOAD_PATH)) do def @view.view_cache_dependencies; []; end - def @view.fragment_cache_key(*); 'ahoy `controller` dependency'; end + def @view.fragment_cache_key(*); "ahoy `controller` dependency"; end - @view.render(partial: 'customers/customer', collection: [ Customer.new('david'), Customer.new('mary') ], cached: true, - locals: { greeting: 'hi' }) + @view.render(partial: "customers/customer", collection: [ Customer.new("david"), Customer.new("mary") ], cached: true, + locals: { greeting: "hi" }) wait assert_equal 1, @logger.logged(:info).size diff --git a/actionview/test/template/number_helper_test.rb b/actionview/test/template/number_helper_test.rb index ace3e950b8..ed31b930dd 100644 --- a/actionview/test/template/number_helper_test.rb +++ b/actionview/test/template/number_helper_test.rb @@ -20,16 +20,16 @@ class NumberHelperTest < ActionView::TestCase assert_equal "&pound;1,234,567,890.50", number_to_currency("1234567890.50", unit: "£") assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("1234567890.50", format: "%n %u") assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("-1234567890.50", negative_format: "%n %u") - assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("-1234567890.50", 'negative_format' => "%n %u") - assert_equal '₹ 12,30,000.00', number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n") + assert_equal "<b>1,234,567,890.50</b> $", number_to_currency("-1234567890.50", "negative_format" => "%n %u") + assert_equal "₹ 12,30,000.00", number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: "₹", format: "%u %n") end def test_number_to_percentage assert_equal nil, number_to_percentage(nil) assert_equal "100.000%", number_to_percentage(100) - assert_equal "100.000 %", number_to_percentage(100, format: '%n %') - assert_equal "<b>100.000</b> %", number_to_percentage(100, format: '%n %') - assert_equal "100.000 %", number_to_percentage(100, format: raw('%n %')) + assert_equal "100.000 %", number_to_percentage(100, format: "%n %") + assert_equal "<b>100.000</b> %", number_to_percentage(100, format: "%n %") + assert_equal "100.000 %", number_to_percentage(100, format: raw("%n %")) assert_equal "100%", number_to_percentage(100, precision: 0) assert_equal "123.4%", number_to_percentage(123.400, precision: 3, strip_insignificant_zeros: true) assert_equal "1.000,000%", number_to_percentage(1000, delimiter: ".", separator: ",") @@ -71,27 +71,27 @@ class NumberHelperTest < ActionView::TestCase def test_number_to_human_escape_units volume = { unit: "ml", thousand: "lt", million: "m3", trillion: "km3", quadrillion: "Pl" } - assert_equal '123 <b>lt</b>', number_to_human(123456, :units => volume) - assert_equal '12 <b>ml</b>', number_to_human(12, :units => volume) - assert_equal '1.23 <b>m3</b>', number_to_human(1234567, :units => volume) - assert_equal '1.23 <b>km3</b>', number_to_human(1_234_567_000_000, :units => volume) - assert_equal '1.23 <b>Pl</b>', number_to_human(1_234_567_000_000_000, :units => volume) + assert_equal "123 <b>lt</b>", number_to_human(123456, :units => volume) + assert_equal "12 <b>ml</b>", number_to_human(12, :units => volume) + assert_equal "1.23 <b>m3</b>", number_to_human(1234567, :units => volume) + assert_equal "1.23 <b>km3</b>", number_to_human(1_234_567_000_000, :units => volume) + assert_equal "1.23 <b>Pl</b>", number_to_human(1_234_567_000_000_000, :units => volume) #Including fractionals distance = { mili: "mm", centi: "cm", deci: "dm", unit: "m", ten: "dam", hundred: "hm", thousand: "km", micro: "um", nano: "nm", pico: "pm", femto: "fm"} - assert_equal '1.23 <b>mm</b>', number_to_human(0.00123, :units => distance) - assert_equal '1.23 <b>cm</b>', number_to_human(0.0123, :units => distance) - assert_equal '1.23 <b>dm</b>', number_to_human(0.123, :units => distance) - assert_equal '1.23 <b>m</b>', number_to_human(1.23, :units => distance) - assert_equal '1.23 <b>dam</b>', number_to_human(12.3, :units => distance) - assert_equal '1.23 <b>hm</b>', number_to_human(123, :units => distance) - assert_equal '1.23 <b>km</b>', number_to_human(1230, :units => distance) - assert_equal '1.23 <b>um</b>', number_to_human(0.00000123, :units => distance) - assert_equal '1.23 <b>nm</b>', number_to_human(0.00000000123, :units => distance) - assert_equal '1.23 <b>pm</b>', number_to_human(0.00000000000123, :units => distance) - assert_equal '1.23 <b>fm</b>', number_to_human(0.00000000000000123, :units => distance) + assert_equal "1.23 <b>mm</b>", number_to_human(0.00123, :units => distance) + assert_equal "1.23 <b>cm</b>", number_to_human(0.0123, :units => distance) + assert_equal "1.23 <b>dm</b>", number_to_human(0.123, :units => distance) + assert_equal "1.23 <b>m</b>", number_to_human(1.23, :units => distance) + assert_equal "1.23 <b>dam</b>", number_to_human(12.3, :units => distance) + assert_equal "1.23 <b>hm</b>", number_to_human(123, :units => distance) + assert_equal "1.23 <b>km</b>", number_to_human(1230, :units => distance) + assert_equal "1.23 <b>um</b>", number_to_human(0.00000123, :units => distance) + assert_equal "1.23 <b>nm</b>", number_to_human(0.00000000123, :units => distance) + assert_equal "1.23 <b>pm</b>", number_to_human(0.00000000000123, :units => distance) + assert_equal "1.23 <b>fm</b>", number_to_human(0.00000000000000123, :units => distance) end def test_number_helpers_escape_delimiter_and_separator @@ -116,9 +116,9 @@ class NumberHelperTest < ActionView::TestCase end def test_number_to_human_with_custom_translation_scope - I18n.backend.store_translations 'ts', + I18n.backend.store_translations "ts", :custom_units_for_number_to_human => {:mili => "mm", :centi => "cm", :deci => "dm", :unit => "m", :ten => "dam", :hundred => "hm", :thousand => "km"} - assert_equal "1.01 cm", number_to_human(0.0101, :locale => 'ts', :units => :custom_units_for_number_to_human) + assert_equal "1.01 cm", number_to_human(0.0101, :locale => "ts", :units => :custom_units_for_number_to_human) ensure I18n.reload! end diff --git a/actionview/test/template/output_safety_helper_test.rb b/actionview/test/template/output_safety_helper_test.rb index b940c9dd36..98b1938276 100644 --- a/actionview/test/template/output_safety_helper_test.rb +++ b/actionview/test/template/output_safety_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class OutputSafetyHelperTest < ActionView::TestCase tests ActionView::Helpers::OutputSafetyHelper @@ -26,11 +26,11 @@ class OutputSafetyHelperTest < ActionView::TestCase end test "safe_join should work recursively similarly to Array.join" do - joined = safe_join(['a',['b','c']], ':') - assert_equal 'a:b:c', joined + joined = safe_join(["a",["b","c"]], ":") + assert_equal "a:b:c", joined - joined = safe_join(['"a"',['','']], '
') - assert_equal '"a" <br/> <b> <br/> <c>', joined + joined = safe_join(['"a"',["",""]], "
") + assert_equal ""a" <br/> <b> <br/> <c>", joined end test "to_sentence should escape non-html_safe values" do @@ -50,9 +50,9 @@ class OutputSafetyHelperTest < ActionView::TestCase end test "to_sentence connector words are checked for html safety" do - assert_equal "one & two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' & '.html_safe) - assert_equal "one & two", to_sentence(['one', 'two'], two_words_connector: ' & '.html_safe) - assert_equal "one, two <script>alert(1)</script> three", to_sentence(['one', 'two', 'three'], last_word_connector: ' ') + assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe) + assert_equal "one & two", to_sentence(["one", "two"], two_words_connector: " & ".html_safe) + assert_equal "one, two <script>alert(1)</script> three", to_sentence(["one", "two", "three"], last_word_connector: " ") end test "to_sentence should not escape html_safe values" do @@ -67,24 +67,24 @@ class OutputSafetyHelperTest < ActionView::TestCase end test "to_sentence handles blank strings" do - actual = to_sentence(['', 'two', 'three']) + actual = to_sentence(["", "two", "three"]) assert actual.html_safe? assert_equal ", two, and three", actual end test "to_sentence handles nil values" do - actual = to_sentence([nil, 'two', 'three']) + actual = to_sentence([nil, "two", "three"]) assert actual.html_safe? assert_equal ", two, and three", actual end test "to_sentence still supports ActiveSupports Array#to_sentence arguments" do - assert_equal "one two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' ') - assert_equal "one & two, and three", to_sentence(['one', 'two', 'three'], words_connector: ' & '.html_safe) - assert_equal "onetwo, and three", to_sentence(['one', 'two', 'three'], words_connector: nil) - assert_equal "one, two, and also three", to_sentence(['one', 'two', 'three'], last_word_connector: ', and also ') - assert_equal "one, twothree", to_sentence(['one', 'two', 'three'], last_word_connector: nil) - assert_equal "one, two three", to_sentence(['one', 'two', 'three'], last_word_connector: ' ') - assert_equal "one, two and three", to_sentence(['one', 'two', 'three'], last_word_connector: ' and ') + assert_equal "one two, and three", to_sentence(["one", "two", "three"], words_connector: " ") + assert_equal "one & two, and three", to_sentence(["one", "two", "three"], words_connector: " & ".html_safe) + assert_equal "onetwo, and three", to_sentence(["one", "two", "three"], words_connector: nil) + assert_equal "one, two, and also three", to_sentence(["one", "two", "three"], last_word_connector: ", and also ") + assert_equal "one, twothree", to_sentence(["one", "two", "three"], last_word_connector: nil) + assert_equal "one, two three", to_sentence(["one", "two", "three"], last_word_connector: " ") + assert_equal "one, two and three", to_sentence(["one", "two", "three"], last_word_connector: " and ") end end diff --git a/actionview/test/template/partial_iteration_test.rb b/actionview/test/template/partial_iteration_test.rb index 695f9f1bef..3ebf3b550a 100644 --- a/actionview/test/template/partial_iteration_test.rb +++ b/actionview/test/template/partial_iteration_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'action_view/renderer/partial_renderer' +require "abstract_unit" +require "action_view/renderer/partial_renderer" class PartialIterationTest < ActiveSupport::TestCase def test_has_size_and_index diff --git a/actionview/test/template/record_identifier_test.rb b/actionview/test/template/record_identifier_test.rb index 04898c0b0e..ce446715fd 100644 --- a/actionview/test/template/record_identifier_test.rb +++ b/actionview/test/template/record_identifier_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'controller/fake_models' +require "abstract_unit" +require "controller/fake_models" class RecordIdentifierTest < ActiveSupport::TestCase include ActionView::RecordIdentifier @@ -7,8 +7,8 @@ class RecordIdentifierTest < ActiveSupport::TestCase def setup @klass = Comment @record = @klass.new - @singular = 'comment' - @plural = 'comments' + @singular = "comment" + @plural = "comments" end def test_dom_id_with_new_record @@ -73,7 +73,7 @@ class RecordIdentifierWithoutActiveModelTest < ActiveSupport::TestCase end def test_dom_class - assert_equal 'airplane', dom_class(@record) + assert_equal "airplane", dom_class(@record) end def test_dom_class_with_prefix @@ -86,6 +86,6 @@ class RecordIdentifierWithoutActiveModelTest < ActiveSupport::TestCase end def test_dom_class_as_singleton_method - assert_equal 'airplane', ActionView::RecordIdentifier.dom_class(@record) + assert_equal "airplane", ActionView::RecordIdentifier.dom_class(@record) end end diff --git a/actionview/test/template/record_tag_helper_test.rb b/actionview/test/template/record_tag_helper_test.rb index bfc5d04bed..2840ad01b2 100644 --- a/actionview/test/template/record_tag_helper_test.rb +++ b/actionview/test/template/record_tag_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class RecordTagPost extend ActiveModel::Naming diff --git a/actionview/test/template/render_test.rb b/actionview/test/template/render_test.rb index 68574d4adb..91c74e0ec2 100644 --- a/actionview/test/template/render_test.rb +++ b/actionview/test/template/render_test.rb @@ -1,12 +1,12 @@ -require 'abstract_unit' -require 'controller/fake_models' +require "abstract_unit" +require "controller/fake_models" class TestController < ActionController::Base end module RenderTestCases def setup_view(paths) - @assigns = { :secret => 'in the sauce' } + @assigns = { :secret => "in the sauce" } @view = Class.new(ActionView::Base) do def view_cache_dependencies; end @@ -18,8 +18,8 @@ module RenderTestCases @controller_view = TestController.new.view_context # Reload and register danish language for testing - I18n.backend.store_translations 'da', {} - I18n.backend.store_translations 'pt-BR', {} + I18n.backend.store_translations "da", {} + I18n.backend.store_translations "pt-BR", {} # Ensure original are still the same since we are reindexing view paths assert_equal ORIGINAL_LOCALES, I18n.available_locales.map(&:to_s).sort @@ -112,7 +112,7 @@ module RenderTestCases end def test_render_ruby_template_inline - assert_equal '4', @view.render(:inline => "(2**2).to_s", :type => :ruby) + assert_equal "4", @view.render(:inline => "(2**2).to_s", :type => :ruby) end def test_render_file_with_localization_on_context_level @@ -130,11 +130,11 @@ module RenderTestCases end def test_render_file_at_top_level - assert_equal 'Elastica', @view.render(:file => '/shared') + assert_equal "Elastica", @view.render(:file => "/shared") end def test_render_file_with_full_path - template_path = File.join(File.dirname(__FILE__), '../fixtures/test/hello_world') + template_path = File.join(File.dirname(__FILE__), "../fixtures/test/hello_world") assert_equal "Hello world!", @view.render(:file => template_path) end @@ -143,7 +143,7 @@ module RenderTestCases end def test_render_file_with_locals - locals = { :secret => 'in the sauce' } + locals = { :secret => "in the sauce" } assert_equal "The secret is in the sauce\n", @view.render(:file => "test/render_file_with_locals", :locals => locals) end @@ -156,7 +156,7 @@ module RenderTestCases end def test_render_outside_path - assert File.exist?(File.join(File.dirname(__FILE__), '../../test/abstract_unit.rb')) + assert File.exist?(File.join(File.dirname(__FILE__), "../../test/abstract_unit.rb")) assert_raises ActionView::MissingTemplate do @view.render(:template => "../\\../test/abstract_unit.rb") end @@ -167,22 +167,22 @@ module RenderTestCases end def test_render_partial_with_format - assert_equal 'partial html', @view.render(:partial => 'test/partial') + assert_equal "partial html", @view.render(:partial => "test/partial") end def test_render_partial_with_selected_format - assert_equal 'partial html', @view.render(:partial => 'test/partial', :formats => :html) - assert_equal 'partial js', @view.render(:partial => 'test/partial', :formats => [:js]) + assert_equal "partial html", @view.render(:partial => "test/partial", :formats => :html) + assert_equal "partial js", @view.render(:partial => "test/partial", :formats => [:js]) end def test_render_partial_at_top_level # file fixtures/_top_level_partial_only (not fixtures/test) - assert_equal 'top level partial', @view.render(:partial => '/top_level_partial_only') + assert_equal "top level partial", @view.render(:partial => "/top_level_partial_only") end def test_render_partial_with_format_at_top_level # file fixtures/_top_level_partial.html (not fixtures/test, with format extension) - assert_equal 'top level partial html', @view.render(:partial => '/top_level_partial') + assert_equal "top level partial html", @view.render(:partial => "/top_level_partial") end def test_render_partial_with_locals @@ -207,7 +207,7 @@ module RenderTestCases end def test_render_partial_starting_with_a_capital - assert_nothing_raised { @view.render(:partial => 'test/FooBar') } + assert_nothing_raised { @view.render(:partial => "test/FooBar") } end def test_render_partial_with_hyphen @@ -219,14 +219,14 @@ module RenderTestCases end def test_render_partial_with_invalid_option_as - e = assert_raises(ArgumentError) { @view.render(:partial => "test/partial_only", :as => 'a-in') } + e = assert_raises(ArgumentError) { @view.render(:partial => "test/partial_only", :as => "a-in") } assert_equal "The value (a-in) of the option `as` is not a valid Ruby identifier; " + "make sure it starts with lowercase letter, " + "and is followed by any combination of letters, numbers and underscores.", e.message end def test_render_partial_with_hyphen_and_invalid_option_as - e = assert_raises(ArgumentError) { @view.render(:partial => "test/a-in", :as => 'a-in') } + e = assert_raises(ArgumentError) { @view.render(:partial => "test/a-in", :as => "a-in") } assert_equal "The value (a-in) of the option `as` is not a valid Ruby identifier; " + "make sure it starts with lowercase letter, " + "and is followed by any combination of letters, numbers and underscores.", e.message @@ -288,7 +288,7 @@ module RenderTestCases def test_render_partial_collection_as_by_string assert_equal "david david davidmary mary mary", - @view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => 'customer') + @view.render(:partial => "test/customer_with_var", :collection => [ Customer.new("david"), Customer.new("mary") ], :as => "customer") end def test_render_partial_collection_as_by_symbol @@ -318,11 +318,11 @@ module RenderTestCases end def test_render_partial_without_object_does_not_put_partial_name_to_local_assigns - assert_equal 'false', @view.render(partial: 'test/partial_name_in_local_assigns') + assert_equal "false", @view.render(partial: "test/partial_name_in_local_assigns") end def test_render_partial_with_nil_object_puts_partial_name_to_local_assigns - assert_equal 'true', @view.render(partial: 'test/partial_name_in_local_assigns', object: nil) + assert_equal "true", @view.render(partial: "test/partial_name_in_local_assigns", object: nil) end def test_render_partial_with_nil_values_in_collection @@ -330,22 +330,22 @@ module RenderTestCases end def test_render_partial_with_layout_using_collection_and_template - assert_equal "Hello: AmazonHello: Yahoo", @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial', :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) + assert_equal "Hello: AmazonHello: Yahoo", @view.render(:partial => "test/customer", :layout => "test/b_layout_for_partial", :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) end def test_render_partial_with_layout_using_collection_and_template_makes_current_item_available_in_layout assert_equal 'Hello: AmazonHello: Yahoo', - @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial_with_object', :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) + @view.render(:partial => "test/customer", :layout => "test/b_layout_for_partial_with_object", :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) end def test_render_partial_with_layout_using_collection_and_template_makes_current_item_counter_available_in_layout assert_equal 'Hello: AmazonHello: Yahoo', - @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial_with_object_counter', :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) + @view.render(:partial => "test/customer", :layout => "test/b_layout_for_partial_with_object_counter", :collection => [ Customer.new("Amazon"), Customer.new("Yahoo") ]) end def test_render_partial_with_layout_using_object_and_template_makes_object_available_in_layout assert_equal 'Hello: Amazon', - @view.render(:partial => "test/customer", :layout => 'test/b_layout_for_partial_with_object', :object => Customer.new("Amazon")) + @view.render(:partial => "test/customer", :layout => "test/b_layout_for_partial_with_object", :object => Customer.new("Amazon")) end def test_render_partial_with_empty_array_should_return_nil @@ -353,11 +353,11 @@ module RenderTestCases end def test_render_partial_using_string - assert_equal "Hello: Anonymous", @controller_view.render('customer') + assert_equal "Hello: Anonymous", @controller_view.render("customer") end def test_render_partial_with_locals_using_string - assert_equal "Hola: david", @controller_view.render('customer_greeting', :greeting => 'Hola', :customer_greeting => Customer.new("david")) + assert_equal "Hola: david", @controller_view.render("customer_greeting", :greeting => "Hola", :customer_greeting => Customer.new("david")) end def test_render_partial_with_object_uses_render_partial_path @@ -430,7 +430,7 @@ module RenderTestCases def test_render_inline_with_render_from_to_proc ActionView::Template.register_template_handler :ruby_handler, :source.to_proc - assert_equal '3', @view.render(inline: "(1 + 2).to_s", type: :ruby_handler) + assert_equal "3", @view.render(inline: "(1 + 2).to_s", type: :ruby_handler) ensure ActionView::Template.unregister_template_handler :ruby_handler end @@ -450,11 +450,11 @@ module RenderTestCases end def test_render_body - assert_equal 'some body', @view.render(body: 'some body') + assert_equal "some body", @view.render(body: "some body") end def test_render_plain - assert_equal 'some plaintext', @view.render(plain: 'some plaintext') + assert_equal "some plaintext", @view.render(plain: "some plaintext") end def test_render_knows_about_types_registered_when_extensions_are_checked_earlier_in_initialization @@ -520,12 +520,12 @@ module RenderTestCases def test_render_partial_and_layout_without_block_with_locals assert_equal %(Before (Foo!)\npartial html\nAfter), - @view.render(:partial => 'test/partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'}) + @view.render(:partial => "test/partial", :layout => "test/layout_for_partial", :locals => { :name => "Foo!"}) end def test_render_partial_and_layout_without_block_with_locals_and_rendering_another_partial assert_equal %(Before (Foo!)\npartial html\npartial with partial\n\nAfter), - @view.render(:partial => 'test/partial_with_partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'}) + @view.render(:partial => "test/partial_with_partial", :layout => "test/layout_for_partial", :locals => { :name => "Foo!"}) end def test_render_partial_shortcut_with_block_content @@ -535,21 +535,21 @@ module RenderTestCases def test_render_layout_with_a_nested_render_layout_call assert_equal %(Before (Foo!)\nBefore (Bar!)\npartial html\nAfter\npartial with layout\n\nAfter), - @view.render(:partial => 'test/partial_with_layout', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'}) + @view.render(:partial => "test/partial_with_layout", :layout => "test/layout_for_partial", :locals => { :name => "Foo!"}) end def test_render_layout_with_a_nested_render_layout_call_using_block_with_render_partial assert_equal %(Before (Foo!)\nBefore (Bar!)\n\n partial html\n\nAfterpartial with layout\n\nAfter), - @view.render(:partial => 'test/partial_with_layout_block_partial', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'}) + @view.render(:partial => "test/partial_with_layout_block_partial", :layout => "test/layout_for_partial", :locals => { :name => "Foo!"}) end def test_render_layout_with_a_nested_render_layout_call_using_block_with_render_content assert_equal %(Before (Foo!)\nBefore (Bar!)\n\n Content from inside layout!\n\nAfterpartial with layout\n\nAfter), - @view.render(:partial => 'test/partial_with_layout_block_content', :layout => 'test/layout_for_partial', :locals => { :name => 'Foo!'}) + @view.render(:partial => "test/partial_with_layout_block_content", :layout => "test/layout_for_partial", :locals => { :name => "Foo!"}) end def test_render_partial_with_layout_raises_descriptive_error - e = assert_raises(ActionView::MissingTemplate) { @view.render(partial: 'test/partial', layout: true) } + e = assert_raises(ActionView::MissingTemplate) { @view.render(partial: "test/partial", layout: true) } assert_match "Missing partial /_true with", e.message end @@ -632,14 +632,14 @@ class LazyViewRenderTest < ActiveSupport::TestCase def test_render_utf8_template_with_incompatible_external_encoding with_external_encoding Encoding::SHIFT_JIS do e = assert_raises(ActionView::Template::Error) { @view.render(:file => "test/utf8", :formats => [:html], :layouts => "layouts/yield") } - assert_match 'Your template was not saved as valid Shift_JIS', e.cause.message + assert_match "Your template was not saved as valid Shift_JIS", e.cause.message end end def test_render_utf8_template_with_partial_with_incompatible_encoding with_external_encoding Encoding::SHIFT_JIS do e = assert_raises(ActionView::Template::Error) { @view.render(:file => "test/utf8_magic_with_bare_partial", :formats => [:html], :layouts => "layouts/yield") } - assert_match 'Your template was not saved as valid Shift_JIS', e.cause.message + assert_match "Your template was not saved as valid Shift_JIS", e.cause.message end end @@ -676,7 +676,7 @@ class CachedCollectionViewRenderTest < ActiveSupport::TestCase customer = Customer.new("david", 1) key = cache_key(customer, "test/_customer") - ActionView::PartialRenderer.collection_cache.write(key, 'Cached') + ActionView::PartialRenderer.collection_cache.write(key, "Cached") assert_not_equal "Cached", @view.render(partial: "test/customer", collection: [customer]) @@ -686,7 +686,7 @@ class CachedCollectionViewRenderTest < ActiveSupport::TestCase customer = Customer.new("david", 1) key = cache_key(customer, "test/_customer") - ActionView::PartialRenderer.collection_cache.write(key, 'Cached') + ActionView::PartialRenderer.collection_cache.write(key, "Cached") assert_equal "Cached", @view.render(partial: "test/customer", collection: [customer], cached: true) @@ -696,7 +696,7 @@ class CachedCollectionViewRenderTest < ActiveSupport::TestCase customer = CachedCustomer.new("david", 1) key = cache_key(customer, "test/_cached_customer") - ActionView::PartialRenderer.collection_cache.write(key, 'Cached') + ActionView::PartialRenderer.collection_cache.write(key, "Cached") assert_equal "Cached", @view.render(partial: "test/cached_customer", collection: [customer], cached: true) diff --git a/actionview/test/template/resolver_cache_test.rb b/actionview/test/template/resolver_cache_test.rb index 1081c13db0..0ecfccd375 100644 --- a/actionview/test/template/resolver_cache_test.rb +++ b/actionview/test/template/resolver_cache_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ResolverCacheTest < ActiveSupport::TestCase def test_inspect_shields_cache_internals diff --git a/actionview/test/template/resolver_patterns_test.rb b/actionview/test/template/resolver_patterns_test.rb index 1a091bd692..2a4a0da197 100644 --- a/actionview/test/template/resolver_patterns_test.rb +++ b/actionview/test/template/resolver_patterns_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class ResolverPatternsTest < ActiveSupport::TestCase def setup diff --git a/actionview/test/template/sanitize_helper_test.rb b/actionview/test/template/sanitize_helper_test.rb index efe846a7eb..c8963fee9c 100644 --- a/actionview/test/template/sanitize_helper_test.rb +++ b/actionview/test/template/sanitize_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" # The exhaustive tests are in test/controller/html/sanitizer_test.rb. # This tests that the helpers hook up correctly to the sanitizer classes. @@ -13,7 +13,7 @@ class SanitizeHelperTest < ActionView::TestCase end def test_sanitize_form - assert_equal '', sanitize("
") + assert_equal "", sanitize("
") end def test_should_sanitize_illegal_style_properties diff --git a/actionview/test/template/streaming_render_test.rb b/actionview/test/template/streaming_render_test.rb index d06ba4ceb0..894512ea31 100644 --- a/actionview/test/template/streaming_render_test.rb +++ b/actionview/test/template/streaming_render_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class TestController < ActionController::Base end @@ -6,7 +6,7 @@ end class FiberedTest < ActiveSupport::TestCase def setup view_paths = ActionController::Base.view_paths - @assigns = { :secret => 'in the sauce', :name => nil } + @assigns = { :secret => "in the sauce", :name => nil } @view = ActionView::Base.new(view_paths, @assigns) @controller_view = TestController.new.view_context end @@ -44,7 +44,7 @@ class FiberedTest < ActiveSupport::TestCase end def test_render_file_with_locals - locals = { :secret => 'in the sauce' } + locals = { :secret => "in the sauce" } assert_equal "The secret is in the sauce\n", buffered_render(:file => "test/render_file_with_locals", :locals => locals) end diff --git a/actionview/test/template/tag_helper_test.rb b/actionview/test/template/tag_helper_test.rb index 4ed3252c63..0c8bfd03d7 100644 --- a/actionview/test/template/tag_helper_test.rb +++ b/actionview/test/template/tag_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class TagHelperTest < ActionView::TestCase include RenderERBUtils @@ -18,7 +18,7 @@ class TagHelperTest < ActionView::TestCase def test_tag_builder_void_tag assert_equal "
", tag.br - assert_equal "
", tag.br(class: 'some_class') + assert_equal "
", tag.br(class: "some_class") end def test_tag_builder_void_tag_with_forced_content @@ -52,11 +52,11 @@ class TagHelperTest < ActionView::TestCase end def test_tag_options_accepts_blank_option - assert_equal "

", tag("p", :included => '') + assert_equal "

", tag("p", :included => "") end def test_tag_builder_options_accepts_blank_option - assert_equal "

", tag.p(included: '') + assert_equal "

", tag.p(included: "") end def test_tag_options_converts_boolean_option @@ -75,9 +75,9 @@ class TagHelperTest < ActionView::TestCase assert_equal content_tag("a", "Create", "href" => "create"), content_tag("a", "Create", :href => "create") assert_equal "

<script>evil_js</script>

", - content_tag(:p, '') + content_tag(:p, "") assert_equal "

", - content_tag(:p, '', nil, false) + content_tag(:p, "", nil, false) end def test_tag_builder_with_content @@ -88,16 +88,16 @@ class TagHelperTest < ActionView::TestCase assert_equal "

<script>evil_js</script>

", tag.p("") assert_equal "

", - tag.p('', escape_attributes: false) + tag.p("", escape_attributes: false) end def test_tag_builder_nested assert_equal "
content
", tag.div { "content" } assert_equal "
hello
", - tag.div(id: 'header') { |tag| tag.span 'hello' } + tag.div(id: "header") { |tag| tag.span "hello" } assert_equal "
hello
", - tag.div(id: 'header') { |tag| tag.div(class: 'world') { tag.span 'hello' } } + tag.div(id: "header") { |tag| tag.div(class: "world") { tag.span "hello" } } end def test_content_tag_with_block_in_erb @@ -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 "

limelight

", str - str = content_tag('p', "limelight", :class => ["song", "play"]) + str = content_tag("p", "limelight", :class => ["song", "play"]) assert_equal "

limelight

", str - str = content_tag('p', "limelight", :class => ["song", ["play"]]) + str = content_tag("p", "limelight", :class => ["song", ["play"]]) assert_equal "

limelight

", 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 "

\">limelight

", str - str = content_tag('p', "limelight", {:class => ["song", ["play>"]]}, false) + str = content_tag("p", "limelight", {:class => ["song", ["play>"]]}, false) assert_equal "

\">limelight

", str end @@ -211,32 +211,32 @@ 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 '

limelight

', str end def test_tag_builder_with_empty_array_class - assert_equal '

limelight

', tag.p('limelight', class: []) + assert_equal '

limelight

', tag.p("limelight", class: []) 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 '

limelight

', str end def test_tag_builder_with_unescaped_empty_array_class - str = tag.p 'limelight', class: [], escape_attributes: false + str = tag.p "limelight", class: [], escape_attributes: false assert_equal '

limelight

', str end def test_content_tag_with_data_attributes assert_dom_equal '

limelight

', - content_tag('p', "limelight", data: { number: 1, string: 'hello', string_with_quotes: 'double"quote"party"' }) + content_tag("p", "limelight", data: { number: 1, string: "hello", string_with_quotes: 'double"quote"party"' }) end def test_tag_builder_with_data_attributes assert_dom_equal '

limelight

', - tag.p("limelight", data: { number: 1, string: 'hello', string_with_quotes: 'double"quote"party"' }) + tag.p("limelight", data: { number: 1, string: "hello", string_with_quotes: 'double"quote"party"' }) end def test_cdata_section @@ -253,73 +253,73 @@ class TagHelperTest < ActionView::TestCase end def test_escape_once - assert_equal '1 < 2 & 3', escape_once('1 < 2 & 3') + assert_equal "1 < 2 & 3", escape_once("1 < 2 & 3") assert_equal " ' ' λ λ " ' < > ", escape_once(" ' ' λ λ \" ' < > ") end def test_tag_honors_html_safe_for_param_values - ['1&2', '1 < 2', '“test“'].each do |escaped| - assert_equal %(), tag('a', :href => escaped.html_safe) + ["1&2", "1 < 2", "“test“"].each do |escaped| + assert_equal %(), tag("a", :href => escaped.html_safe) assert_equal %(), tag.a(href: escaped.html_safe) end end def test_tag_honors_html_safe_with_escaped_array_class - assert_equal '

', tag('p', :class => ['song>', raw('play>')]) - assert_equal '

', tag('p', :class => [raw('song>'), 'play>']) + assert_equal '

', tag("p", :class => ["song>", raw("play>")]) + assert_equal '

', tag("p", :class => [raw("song>"), "play>"]) end def test_tag_builder_honors_html_safe_with_escaped_array_class - assert_equal '

', tag.p(class: ['song>', raw('play>')]) - assert_equal '

', tag.p(class: [raw('song>'), 'play>']) + assert_equal '

', tag.p(class: ["song>", raw("play>")]) + assert_equal '

', tag.p(class: [raw("song>"), "play>"]) end def test_skip_invalid_escaped_attributes - ['&1;', 'dfa3;', '& #123;'].each do |escaped| - assert_equal %(), tag('a', :href => escaped) + ["&1;", "dfa3;", "& #123;"].each do |escaped| + assert_equal %(), tag("a", :href => escaped) assert_equal %(), tag.a(href: escaped) end end def test_disable_escaping - assert_equal '', tag('a', { :href => '&' }, false, false) + assert_equal '', tag("a", { :href => "&" }, false, false) end def test_tag_builder_disable_escaping - assert_equal '', tag.a(href: '&', escape_attributes: false) - assert_equal 'cnt', tag.a(href: '&' , escape_attributes: false) { "cnt"} - assert_equal '
', tag.br("data-hidden": '&' , escape_attributes: false) - assert_equal 'content', tag.a("content", href: '&', escape_attributes: false) - assert_equal 'content', tag.a(href: '&', escape_attributes: false) { "content"} + assert_equal '', tag.a(href: "&", escape_attributes: false) + assert_equal 'cnt', tag.a(href: "&" , escape_attributes: false) { "cnt"} + assert_equal '
', tag.br("data-hidden": "&" , escape_attributes: false) + assert_equal 'content', tag.a("content", href: "&", escape_attributes: false) + assert_equal 'content', tag.a(href: "&", escape_attributes: false) { "content"} end def test_data_attributes - ['data', :data].each { |data| + ["data", :data].each { |data| assert_dom_equal '', - tag('a', { data => { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: 'hello', symbol: :foo, array: [1, 2, 3], hash: { key: 'value'}, string_with_quotes: 'double"quote"party"' } }) + tag("a", { data => { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: "hello", symbol: :foo, array: [1, 2, 3], hash: { key: "value"}, string_with_quotes: 'double"quote"party"' } }) assert_dom_equal '', - tag.a(data: { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: 'hello', symbol: :foo, array: [1, 2, 3], hash: { key: 'value'}, string_with_quotes: 'double"quote"party"' }) + tag.a(data: { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: "hello", symbol: :foo, array: [1, 2, 3], hash: { key: "value"}, string_with_quotes: 'double"quote"party"' }) } end def test_aria_attributes - ['aria', :aria].each { |aria| + ["aria", :aria].each { |aria| assert_dom_equal '', - tag('a', { aria => { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: 'hello', symbol: :foo, array: [1, 2, 3], hash: { key: 'value'}, string_with_quotes: 'double"quote"party"' } }) + tag("a", { aria => { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: "hello", symbol: :foo, array: [1, 2, 3], hash: { key: "value"}, string_with_quotes: 'double"quote"party"' } }) assert_dom_equal '', - tag.a(aria: { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: 'hello', symbol: :foo, array: [1, 2, 3], hash: { key: 'value'}, string_with_quotes: 'double"quote"party"' }) + tag.a(aria: { a_float: 3.14, a_big_decimal: BigDecimal.new("-123.456"), a_number: 1, string: "hello", symbol: :foo, array: [1, 2, 3], hash: { key: "value"}, string_with_quotes: 'double"quote"party"' }) } end def test_link_to_data_nil_equal - div_type1 = content_tag(:div, 'test', { 'data-tooltip' => nil }) - div_type2 = content_tag(:div, 'test', { data: {tooltip: nil} }) + div_type1 = content_tag(:div, "test", { "data-tooltip" => nil }) + div_type2 = content_tag(:div, "test", { data: {tooltip: nil} }) assert_dom_equal div_type1, div_type2 end def test_tag_builder_link_to_data_nil_equal - div_type1 = tag.div 'test', { 'data-tooltip': nil } - div_type2 = tag.div 'test', { data: {tooltip: nil} } + div_type1 = tag.div "test", { 'data-tooltip': nil } + div_type2 = tag.div "test", { data: {tooltip: nil} } assert_dom_equal div_type1, div_type2 end diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index d69d5819b6..02167caa71 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -1,5 +1,5 @@ -require 'abstract_unit' -require 'rails/engine' +require "abstract_unit" +require "rails/engine" module ActionView @@ -8,13 +8,13 @@ module ActionView module AnotherTestHelper def from_another_helper - 'Howdy!' + "Howdy!" end end module ASharedTestHelper def from_shared_helper - 'Holla!' + "Holla!" end end @@ -27,7 +27,7 @@ module ActionView test_case.class_eval do test "helpers defined on ActionView::TestCase are available" do assert test_case.ancestors.include?(ASharedTestHelper) - assert_equal 'Holla!', from_shared_helper + assert_equal "Holla!", from_shared_helper end end end @@ -55,7 +55,7 @@ module ActionView end test "works without testing a helper module" do - assert_equal 'Eloy', render('developers/developer', :developer => DeveloperStruct.new('Eloy')) + assert_equal "Eloy", render("developers/developer", :developer => DeveloperStruct.new("Eloy")) end test "can render a layout with block" do @@ -66,7 +66,7 @@ module ActionView helper AnotherTestHelper test "additional helper classes can be specified as in a controller" do assert test_case.ancestors.include?(AnotherTestHelper) - assert_equal 'Howdy!', from_another_helper + assert_equal "Howdy!", from_another_helper end test "determine_default_helper_class returns nil if the test name constant resolves to a class" do @@ -103,38 +103,38 @@ module ActionView helper AnotherTestHelper test "additional helper classes can be specified as in a controller" do assert test_case.ancestors.include?(AnotherTestHelper) - assert_equal 'Howdy!', from_another_helper + assert_equal "Howdy!", from_another_helper test_case.helper_class.module_eval do def render_from_helper from_another_helper end end - assert_equal 'Howdy!', render(:partial => 'test/from_helper') + assert_equal "Howdy!", render(:partial => "test/from_helper") end end class HelperInclusionTest < ActionView::TestCase module RenderHelper def render_from_helper - render :partial => 'customer', :collection => @customers + render :partial => "customer", :collection => @customers end end helper RenderHelper test "helper class that is being tested is always included in view instance" do - @controller.controller_path = 'test' + @controller.controller_path = "test" - @customers = [DeveloperStruct.new('Eloy'), DeveloperStruct.new('Manfred')] - assert_match(/Hello: EloyHello: Manfred/, render(:partial => 'test/from_helper')) + @customers = [DeveloperStruct.new("Eloy"), DeveloperStruct.new("Manfred")] + assert_match(/Hello: EloyHello: Manfred/, render(:partial => "test/from_helper")) end end class ControllerHelperMethod < ActionView::TestCase module SomeHelper def some_method - render :partial => 'test/from_helper' + render :partial => "test/from_helper" end end @@ -148,21 +148,21 @@ module ActionView EOF @controller.class.helper_method :render_from_helper - assert_equal 'controller_helper_method', some_method + assert_equal "controller_helper_method", some_method end end class ViewAssignsTest < ActionView::TestCase test "view_assigns returns a Hash of user defined ivars" do - @a = 'b' - @c = 'd' - assert_equal({:a => 'b', :c => 'd'}, view_assigns) + @a = "b" + @c = "d" + assert_equal({:a => "b", :c => "d"}, view_assigns) end test "view_assigns excludes internal ivars" do INTERNAL_IVARS.each do |ivar| assert defined?(ivar), "expected #{ivar} to be defined" - assert !view_assigns.keys.include?(ivar.to_s.tr('@', '').to_sym), "expected #{ivar} to be excluded from view_assigns" + assert !view_assigns.keys.include?(ivar.to_s.tr("@", "").to_sym), "expected #{ivar} to be excluded from view_assigns" end end end @@ -174,10 +174,10 @@ module ActionView end end) test "is able to make methods available to the view" do - assert_equal 'Word!', render(:partial => 'test/from_helper') + assert_equal "Word!", render(:partial => "test/from_helper") end - def from_test_case; 'Word!'; end + def from_test_case; "Word!"; end helper_method :from_test_case end @@ -207,7 +207,7 @@ module ActionView test "a configured test controller is available" do assert_kind_of ActionController::Base, controller - assert_equal '', controller.controller_path + assert_equal "", controller.controller_path end test "no additional helpers should shared across test cases" do @@ -216,16 +216,16 @@ module ActionView end test "is able to use routes" do - controller.request.assign_parameters(@routes, 'foo', 'index', {}, '/foo', []) - assert_equal '/foo', url_for - assert_equal '/bar', url_for(:controller => 'bar') + controller.request.assign_parameters(@routes, "foo", "index", {}, "/foo", []) + assert_equal "/foo", url_for + assert_equal "/bar", url_for(:controller => "bar") end test "is able to use named routes" do with_routing do |set| set.draw { resources :contents } - assert_equal 'http://test.host/contents/new', new_content_url - assert_equal 'http://test.host/contents/1', content_url(:id => 1) + assert_equal "http://test.host/contents/new", new_content_url + assert_equal "http://test.host/contents/1", content_url(:id => 1) end end @@ -244,7 +244,7 @@ module ActionView set.draw { mount app => "/foo", :as => "foo_app" } - assert_equal '/foo/bar', foo_app.bar_path + assert_equal "/foo/bar", foo_app.bar_path end end @@ -257,21 +257,21 @@ module ActionView end end - assert_equal 'http://test.host/contents/new', render(:partial => 'test/from_helper') + assert_equal "http://test.host/contents/new", render(:partial => "test/from_helper") end end test "is able to render partials with local variables" do - assert_equal 'Eloy', render('developers/developer', :developer => DeveloperStruct.new('Eloy')) - assert_equal 'Eloy', render(:partial => 'developers/developer', - :locals => { :developer => DeveloperStruct.new('Eloy') }) + assert_equal "Eloy", render("developers/developer", :developer => DeveloperStruct.new("Eloy")) + assert_equal "Eloy", render(:partial => "developers/developer", + :locals => { :developer => DeveloperStruct.new("Eloy") }) end test "is able to render partials from templates and also use instance variables" do @controller.controller_path = "test" - @customers = [DeveloperStruct.new('Eloy'), DeveloperStruct.new('Manfred')] - assert_match(/Hello: EloyHello: Manfred/, render(:file => 'test/list')) + @customers = [DeveloperStruct.new("Eloy"), DeveloperStruct.new("Manfred")] + assert_match(/Hello: EloyHello: Manfred/, render(:file => "test/list")) end test "is able to render partials from templates and also use instance variables after view has been referenced" do @@ -279,37 +279,37 @@ module ActionView view - @customers = [DeveloperStruct.new('Eloy'), DeveloperStruct.new('Manfred')] - assert_match(/Hello: EloyHello: Manfred/, render(:file => 'test/list')) + @customers = [DeveloperStruct.new("Eloy"), DeveloperStruct.new("Manfred")] + assert_match(/Hello: EloyHello: Manfred/, render(:file => "test/list")) end end class AssertionsTest < ActionView::TestCase def render_from_helper - form_tag('/foo') do - safe_concat render(:text => '
  • foo
') + form_tag("/foo") do + safe_concat render(:text => "
  • foo
") end end helper_method :render_from_helper test "uses the output_buffer for assert_select" do - render(:partial => 'test/from_helper') + render(:partial => "test/from_helper") - assert_select 'form' do - assert_select 'li', :text => 'foo' + assert_select "form" do + assert_select "li", :text => "foo" end end test "do not memoize the document_root_element in view tests" do - concat form_tag('/foo') + concat form_tag("/foo") - assert_select 'form' + assert_select "form" - concat content_tag(:b, 'Strong', class: 'foo') + concat content_tag(:b, "Strong", class: "foo") - assert_select 'form' - assert_select 'b.foo' + assert_select "form" + assert_select "b.foo" end end diff --git a/actionview/test/template/test_test.rb b/actionview/test/template/test_test.rb index e1ff639979..47d57c0c04 100644 --- a/actionview/test/template/test_test.rb +++ b/actionview/test/template/test_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" module PeopleHelper def title(text) @@ -41,7 +41,7 @@ class PeopleHelperTest < ActionView::TestCase extend ActiveModel::Naming def to_model; self; end def persisted?; true; end - def self.name; 'Minitest::Mock'; end + def self.name; "Minitest::Mock"; end }.new "David" the_model = nil @@ -60,7 +60,7 @@ class PeopleHelperTest < ActionView::TestCase def with_test_route_set with_routing do |set| set.draw do - get 'people', :to => 'people#index', :as => :people + get "people", :to => "people#index", :as => :people end yield end @@ -84,7 +84,7 @@ class CrazySymbolHelperTest < ActionView::TestCase end class CrazyStringHelperTest < ActionView::TestCase - tests 'people' + tests "people" def test_set_helper_class_using_string assert_equal PeopleHelper, self.class.helper_class diff --git a/actionview/test/template/testing/fixture_resolver_test.rb b/actionview/test/template/testing/fixture_resolver_test.rb index d6cfa997cd..aae56ff472 100644 --- a/actionview/test/template/testing/fixture_resolver_test.rb +++ b/actionview/test/template/testing/fixture_resolver_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class FixtureResolverTest < ActiveSupport::TestCase def test_should_return_empty_list_for_unknown_path diff --git a/actionview/test/template/testing/null_resolver_test.rb b/actionview/test/template/testing/null_resolver_test.rb index 55ec36e753..c0e02bd9b7 100644 --- a/actionview/test/template/testing/null_resolver_test.rb +++ b/actionview/test/template/testing/null_resolver_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class NullResolverTest < ActiveSupport::TestCase def test_should_return_template_for_any_path diff --git a/actionview/test/template/text_helper_test.rb b/actionview/test/template/text_helper_test.rb index 03c7597505..8c866040d9 100644 --- a/actionview/test/template/text_helper_test.rb +++ b/actionview/test/template/text_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class TextHelperTest < ActionView::TestCase tests ActionView::Helpers::TextHelper @@ -11,9 +11,9 @@ class TextHelperTest < ActionView::TestCase end def test_concat - self.output_buffer = 'foo' - assert_equal 'foobar', concat('bar') - assert_equal 'foobar', output_buffer + self.output_buffer = "foo" + assert_equal "foobar", concat("bar") + assert_equal "foobar", output_buffer end def test_simple_format_should_be_html_safe @@ -38,8 +38,8 @@ class TextHelperTest < ActionView::TestCase text = "A\r\n \nB\n\n\r\n\t\nC\nD".freeze assert_equal "

A\n
\n
B

\n\n

\t\n
C\n
D

", simple_format(text) - assert_equal %q(

This is a classy test

), simple_format("This is a classy test", :class => 'test') - assert_equal %Q(

para 1

\n\n

para 2

), simple_format("para 1\n\npara 2", :class => 'test') + assert_equal %q(

This is a classy test

), simple_format("This is a classy test", :class => "test") + assert_equal %Q(

para 1

\n\n

para 2

), simple_format("para 1\n\npara 2", :class => "test") end def test_simple_format_should_sanitize_input_when_sanitize_option_is_not_false @@ -47,8 +47,8 @@ class TextHelperTest < ActionView::TestCase end def test_simple_format_should_sanitize_input_when_sanitize_option_is_true - assert_equal '

test with unsafe string code!

', - simple_format(' test with unsafe string ', {}, sanitize: true) + assert_equal "

test with unsafe string code!

", + simple_format(" test with unsafe string ", {}, sanitize: true) end def test_simple_format_should_not_sanitize_input_when_sanitize_option_is_false @@ -98,9 +98,9 @@ class TextHelperTest < ActionView::TestCase assert_equal "This is a string that wil[...]", truncate("This is a string that will go longer then the default truncate length of 30", :omission => "[...]") assert_equal "Hello W...", truncate("Hello World!", :length => 10) assert_equal "Hello[...]", truncate("Hello World!", :omission => "[...]", :length => 10) - assert_equal "Hello[...]", truncate("Hello Big World!", :omission => "[...]", :length => 13, :separator => ' ') - assert_equal "Hello Big[...]", truncate("Hello Big World!", :omission => "[...]", :length => 14, :separator => ' ') - assert_equal "Hello Big[...]", truncate("Hello Big World!", :omission => "[...]", :length => 15, :separator => ' ') + assert_equal "Hello[...]", truncate("Hello Big World!", :omission => "[...]", :length => 13, :separator => " ") + assert_equal "Hello Big[...]", truncate("Hello Big World!", :omission => "[...]", :length => 14, :separator => " ") + assert_equal "Hello Big[...]", truncate("Hello Big World!", :omission => "[...]", :length => 15, :separator => " ") end def test_truncate_multibyte @@ -117,7 +117,7 @@ class TextHelperTest < ActionView::TestCase def test_truncate_with_link_options assert_equal "Here is a long test and ...
Continue", - truncate("Here is a long test and I need a continue to read link", :length => 27) { link_to 'Continue', '#' } + truncate("Here is a long test and I need a continue to read link", :length => 27) { link_to "Continue", "#" } end def test_truncate_should_be_html_safe @@ -138,22 +138,22 @@ class TextHelperTest < ActionView::TestCase end def test_truncate_with_block_should_be_html_safe - truncated = truncate("Here's a long test and I need a continue to read link", :length => 27) { link_to 'Continue', '#' } + truncated = truncate("Here's a long test and I need a continue to read link", :length => 27) { link_to "Continue", "#" } assert truncated.html_safe? end def test_truncate_with_block_should_escape_the_input assert_equal "<script>code!</script>He...Continue", - truncate("Here's a long test and I need a continue to read link", :length => 27) { link_to 'Continue', '#' } + truncate("Here's a long test and I need a continue to read link", :length => 27) { link_to "Continue", "#" } end def test_truncate_with_block_should_not_escape_the_input_with_escape_false assert_equal "He...Continue", - truncate("Here's a long test and I need a continue to read link", :length => 27, :escape => false) { link_to 'Continue', '#' } + truncate("Here's a long test and I need a continue to read link", :length => 27, :escape => false) { link_to "Continue", "#" } end def test_truncate_with_block_with_escape_false_should_be_html_safe - truncated = truncate("Here's a long test and I need a continue to read link", :length => 27, :escape => false) { link_to 'Continue', '#' } + truncated = truncate("Here's a long test and I need a continue to read link", :length => 27, :escape => false) { link_to "Continue", "#" } assert truncated.html_safe? end @@ -189,11 +189,11 @@ class TextHelperTest < ActionView::TestCase end def test_highlight_pending - assert_equal ' ', highlight(' ', 'blank text is returned verbatim') + assert_equal " ", highlight(" ", "blank text is returned verbatim") end def test_highlight_should_return_blank_string_for_nil - assert_equal '', highlight(nil, 'blank string is returned for nil') + assert_equal "", highlight(nil, "blank string is returned for nil") end def test_highlight_should_sanitize_input @@ -233,7 +233,7 @@ class TextHelperTest < ActionView::TestCase end def test_highlight_with_multiple_phrases_in_one_pass - assert_equal %(wow em), highlight('wow em', %w(wow em), :highlighter => '\1') + assert_equal %(wow em), highlight("wow em", %w(wow em), :highlighter => '\1') end def test_highlight_with_html @@ -285,17 +285,17 @@ class TextHelperTest < ActionView::TestCase end def test_excerpt_with_regex - assert_equal('...is a beautiful! mor...', excerpt('This is a beautiful! morning', 'beautiful', :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', 'beautiful', :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\bbeau\w*\b/i, :radius => 5)) - assert_equal('...is a beautiful? mor...', excerpt('This is a beautiful? morning', /\b(beau\w*)\b/i, :radius => 5)) + assert_equal("...is a beautiful! mor...", excerpt("This is a beautiful! morning", "beautiful", :radius => 5)) + assert_equal("...is a beautiful? mor...", excerpt("This is a beautiful? morning", "beautiful", :radius => 5)) + assert_equal("...is a beautiful? mor...", excerpt("This is a beautiful? morning", /\bbeau\w*\b/i, :radius => 5)) + assert_equal("...is a beautiful? mor...", excerpt("This is a beautiful? morning", /\b(beau\w*)\b/i, :radius => 5)) assert_equal("...udge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, :radius => 5)) - assert_equal("...judge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, :radius => 1, :separator => ' ')) + assert_equal("...judge Allen and...", excerpt("This day was challenging for judge Allen and his colleagues.", /\ballen\b/i, :radius => 1, :separator => " ")) assert_equal("...was challenging for...", excerpt("This day was challenging for judge Allen and his colleagues.", /\b(\w*allen\w*)\b/i, :radius => 5)) end def test_excerpt_should_not_be_html_safe - assert !excerpt('This is a beautiful! morning', 'beautiful', :radius => 5).html_safe? + assert !excerpt("This is a beautiful! morning", "beautiful", :radius => 5).html_safe? end def test_excerpt_in_borderline_cases @@ -325,7 +325,7 @@ class TextHelperTest < ActionView::TestCase end def test_excerpt_with_utf8 - assert_equal("...\357\254\203ciency could not be...".force_encoding(Encoding::UTF_8), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding(Encoding::UTF_8), 'could', :radius => 8)) + assert_equal("...\357\254\203ciency could not be...".force_encoding(Encoding::UTF_8), excerpt("That's why e\357\254\203ciency could not be helped".force_encoding(Encoding::UTF_8), "could", :radius => 8)) end def test_excerpt_does_not_modify_the_options_hash @@ -336,19 +336,19 @@ class TextHelperTest < ActionView::TestCase end def test_excerpt_with_separator - options = { :separator => ' ', :radius => 1 } - assert_equal('...a very beautiful...', excerpt('This is a very beautiful morning', 'very', options)) - assert_equal('This is...', excerpt('This is a very beautiful morning', 'this', options)) - assert_equal('...beautiful morning', excerpt('This is a very beautiful morning', 'morning', options)) + options = { :separator => " ", :radius => 1 } + assert_equal("...a very beautiful...", excerpt("This is a very beautiful morning", "very", options)) + assert_equal("This is...", excerpt("This is a very beautiful morning", "this", options)) + assert_equal("...beautiful morning", excerpt("This is a very beautiful morning", "morning", options)) options = { :separator => "\n", :radius => 0 } - assert_equal("...very long...", excerpt("my very\nvery\nvery long\nstring", 'long', options)) + assert_equal("...very long...", excerpt("my very\nvery\nvery long\nstring", "long", options)) options = { :separator => "\n", :radius => 1 } - assert_equal("...very\nvery long\nstring", excerpt("my very\nvery\nvery long\nstring", 'long', options)) + assert_equal("...very\nvery long\nstring", excerpt("my very\nvery\nvery long\nstring", "long", options)) - assert_equal excerpt('This is a beautiful morning', 'a'), - excerpt('This is a beautiful morning', 'a', separator: nil) + assert_equal excerpt("This is a beautiful morning", "a"), + excerpt("This is a beautiful morning", "a", separator: nil) end def test_word_wrap @@ -373,12 +373,12 @@ class TextHelperTest < ActionView::TestCase def test_pluralization assert_equal("1 count", pluralize(1, "count")) assert_equal("2 counts", pluralize(2, "count")) - assert_equal("1 count", pluralize('1', "count")) - assert_equal("2 counts", pluralize('2', "count")) - assert_equal("1,066 counts", pluralize('1,066', "count")) - assert_equal("1.25 counts", pluralize('1.25', "count")) - assert_equal("1.0 count", pluralize('1.0', "count")) - assert_equal("1.00 count", pluralize('1.00', "count")) + assert_equal("1 count", pluralize("1", "count")) + assert_equal("2 counts", pluralize("2", "count")) + assert_equal("1,066 counts", pluralize("1,066", "count")) + assert_equal("1.25 counts", pluralize("1.25", "count")) + assert_equal("1.0 count", pluralize("1.0", "count")) + assert_equal("1.00 count", pluralize("1.00", "count")) assert_equal("2 counters", pluralize(2, "count", plural: "counters")) assert_equal("0 counters", pluralize(nil, "count", plural: "counters")) assert_equal("2 people", pluralize(2, "person")) @@ -394,7 +394,7 @@ class TextHelperTest < ActionView::TestCase I18n.locale = :de ActiveSupport::Inflector.inflections(:de) do |inflect| - inflect.irregular 'region', 'regionen' + inflect.irregular "region", "regionen" end assert_equal("1 region", pluralize(1, "region")) @@ -407,7 +407,7 @@ class TextHelperTest < ActionView::TestCase def test_deprecated_plural_as_positional_argument assert_deprecated do - pluralize(2, 'count', 'counters') + pluralize(2, "count", "counters") end end diff --git a/actionview/test/template/text_test.rb b/actionview/test/template/text_test.rb index d899d54589..6510688f97 100644 --- a/actionview/test/template/text_test.rb +++ b/actionview/test/template/text_test.rb @@ -1,17 +1,17 @@ -require 'abstract_unit' +require "abstract_unit" class TextTest < ActiveSupport::TestCase - test 'formats returns symbol for recognized MIME type' do - assert_equal [:text], ActionView::Template::Text.new('', :text).formats + test "formats returns symbol for recognized MIME type" do + assert_equal [:text], ActionView::Template::Text.new("", :text).formats end - test 'formats returns string for recognized MIME type when MIME does not have symbol' do + test "formats returns string for recognized MIME type when MIME does not have symbol" do foo = Mime::Type.lookup("foo") assert_nil foo.to_sym - assert_equal ['foo'], ActionView::Template::Text.new('', foo).formats + assert_equal ["foo"], ActionView::Template::Text.new("", foo).formats end - test 'formats returns string for unknown MIME type' do - assert_equal ['foo'], ActionView::Template::Text.new('', 'foo').formats + test "formats returns string for unknown MIME type" do + assert_equal ["foo"], ActionView::Template::Text.new("", "foo").formats end end diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index 38b9284767..909eb1e50a 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -1,9 +1,9 @@ -require 'abstract_unit' +require "abstract_unit" module I18n class CustomExceptionHandler def self.call(exception, locale, key, options) - 'from CustomExceptionHandler' + "from CustomExceptionHandler" end end end @@ -17,20 +17,20 @@ class TranslationHelperTest < ActiveSupport::TestCase I18n.backend.store_translations(:en, :translations => { :templates => { - :found => { :foo => 'Foo' }, - :array => { :foo => { :bar => 'Foo Bar' } }, - :default => { :foo => 'Foo' } + :found => { :foo => "Foo" }, + :array => { :foo => { :bar => "Foo Bar" } }, + :default => { :foo => "Foo" } }, - :foo => 'Foo', - :hello => 'Hello World', - :html => 'Hello World', - :hello_html => 'Hello World', - :interpolated_html => 'Hello %{word}', + :foo => "Foo", + :hello => "Hello World", + :html => "Hello World", + :hello_html => "Hello World", + :interpolated_html => "Hello %{word}", :array_html => %w(foo bar), :array => %w(foo bar), :count_html => { - :one => 'One %{count}', - :other => 'Other %{count}' + :one => "One %{count}", + :other => "Other %{count}" } } ) @@ -42,8 +42,8 @@ class TranslationHelperTest < ActiveSupport::TestCase end def test_delegates_setting_to_i18n - assert_called_with(I18n, :translate, [:foo, :locale => 'en', :raise => true], returns: "") do - translate :foo, :locale => 'en' + assert_called_with(I18n, :translate, [:foo, :locale => "en", :raise => true], returns: "") do + translate :foo, :locale => "en" end end @@ -58,7 +58,7 @@ class TranslationHelperTest < ActiveSupport::TestCase old_value = ActionView::Base.debug_missing_translation ActionView::Base.debug_missing_translation = false - expected = 'translation missing: en.translations.missing' + expected = "translation missing: en.translations.missing" assert_equal expected, translate(:"translations.missing") ensure ActionView::Base.debug_missing_translation = old_value @@ -78,10 +78,10 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_returns_missing_translation_message_does_filters_out_i18n_options expected = 'Missing' - assert_equal expected, translate(:"translations.missing", year: '2015', default: []) + assert_equal expected, translate(:"translations.missing", year: "2015", default: []) expected = 'Missing' - assert_equal expected, translate(:"translations.missing", year: '2015', scope: %i(scoped)) + assert_equal expected, translate(:"translations.missing", year: "2015", scope: %i(scoped)) end def test_raises_missing_translation_message_with_raise_config_option @@ -103,7 +103,7 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_uses_custom_exception_handler_when_specified old_exception_handler = I18n.exception_handler I18n.exception_handler = I18n::CustomExceptionHandler - assert_equal 'from CustomExceptionHandler', translate(:"translations.missing", raise: false) + assert_equal "from CustomExceptionHandler", translate(:"translations.missing", raise: false) ensure I18n.exception_handler = old_exception_handler end @@ -111,7 +111,7 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_uses_custom_exception_handler_when_specified_for_html old_exception_handler = I18n.exception_handler I18n.exception_handler = I18n::CustomExceptionHandler - assert_equal 'from CustomExceptionHandler', translate(:"translations.missing_html", raise: false) + assert_equal "from CustomExceptionHandler", translate(:"translations.missing_html", raise: false) ensure I18n.exception_handler = old_exception_handler end @@ -122,20 +122,20 @@ class TranslationHelperTest < ActiveSupport::TestCase end def test_finds_translation_scoped_by_partial - assert_equal 'Foo', view.render(:file => 'translations/templates/found').strip + assert_equal "Foo", view.render(:file => "translations/templates/found").strip end def test_finds_array_of_translations_scoped_by_partial - assert_equal 'Foo Bar', @view.render(:file => 'translations/templates/array').strip + assert_equal "Foo Bar", @view.render(:file => "translations/templates/array").strip end def test_default_lookup_scoped_by_partial - assert_equal 'Foo', view.render(:file => 'translations/templates/default').strip + assert_equal "Foo", view.render(:file => "translations/templates/default").strip end def test_missing_translation_scoped_by_partial expected = 'Missing' - assert_equal expected, view.render(:file => 'translations/templates/missing').strip + assert_equal expected, view.render(:file => "translations/templates/missing").strip end def test_translate_does_not_mark_plain_text_as_safe_html @@ -152,14 +152,14 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_translate_escapes_interpolations_in_translations_with_a_html_suffix word_struct = Struct.new(:to_s) - assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => '') - assert_equal 'Hello <World>', translate(:'translations.interpolated_html', :word => word_struct.new("")) + assert_equal "Hello <World>", translate(:'translations.interpolated_html', :word => "") + assert_equal "Hello <World>", translate(:'translations.interpolated_html', :word => word_struct.new("")) end def test_translate_with_html_count - assert_equal 'One 1', translate(:'translations.count_html', :count => 1) - assert_equal 'Other 2', translate(:'translations.count_html', :count => 2) - assert_equal 'Other <One>', translate(:'translations.count_html', :count => '') + assert_equal "One 1", translate(:'translations.count_html', :count => 1) + assert_equal "Other 2", translate(:'translations.count_html', :count => 2) + assert_equal "Other <One>", translate(:'translations.count_html', :count => "") end def test_translation_returning_an_array_ignores_html_suffix @@ -168,7 +168,7 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_translate_with_default_named_html translation = translate(:'translations.missing', :default => :'translations.hello_html') - assert_equal 'Hello World', translation + assert_equal "Hello World", translation assert_equal true, translation.html_safe? end @@ -187,25 +187,25 @@ class TranslationHelperTest < ActiveSupport::TestCase def test_translate_with_two_defaults_named_html translation = translate(:'translations.missing', :default => [:'translations.missing_html', :'translations.hello_html']) - assert_equal 'Hello World', translation + assert_equal "Hello World", translation assert_equal true, translation.html_safe? end def test_translate_with_last_default_named_html translation = translate(:'translations.missing', :default => [:'translations.missing', :'translations.hello_html']) - assert_equal 'Hello World', translation + assert_equal "Hello World", translation assert_equal true, translation.html_safe? end def test_translate_with_last_default_not_named_html translation = translate(:'translations.missing', :default => [:'translations.missing_html', :'translations.foo']) - assert_equal 'Foo', translation + assert_equal "Foo", translation assert_equal false, translation.html_safe? end def test_translate_with_string_default - translation = translate(:'translations.missing', default: 'A Generic String') - assert_equal 'A Generic String', translation + translation = translate(:'translations.missing', default: "A Generic String") + assert_equal "A Generic String", translation end def test_translate_with_object_default @@ -214,13 +214,13 @@ class TranslationHelperTest < ActiveSupport::TestCase end def test_translate_with_array_of_string_defaults - translation = translate(:'translations.missing', default: ['A Generic String', 'Second generic string']) - assert_equal 'A Generic String', translation + translation = translate(:'translations.missing', default: ["A Generic String", "Second generic string"]) + assert_equal "A Generic String", translation end def test_translate_with_array_of_defaults_with_nil - translation = translate(:'translations.missing', default: [:'also_missing', nil, 'A Generic String']) - assert_equal 'A Generic String', translation + translation = translate(:'translations.missing', default: [:'also_missing', nil, "A Generic String"]) + assert_equal "A Generic String", translation end def test_translate_with_array_of_array_default diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 6060ea2f1e..66259ac01f 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -1,4 +1,4 @@ -require 'abstract_unit' +require "abstract_unit" class UrlHelperTest < ActiveSupport::TestCase @@ -43,59 +43,59 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_url_for_with_back - referer = 'http://www.example.com/referer' + referer = "http://www.example.com/referer" @controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer)) - assert_equal 'http://www.example.com/referer', url_for(:back) + assert_equal "http://www.example.com/referer", url_for(:back) end def test_url_for_with_back_and_no_referer @controller = Struct.new(:request).new(Struct.new(:env).new({})) - assert_equal 'javascript:history.back()', url_for(:back) + assert_equal "javascript:history.back()", url_for(:back) end def test_url_for_with_back_and_no_controller @controller = nil - assert_equal 'javascript:history.back()', url_for(:back) + assert_equal "javascript:history.back()", url_for(:back) end def test_url_for_with_back_and_javascript_referer - referer = 'javascript:alert(document.cookie)' + referer = "javascript:alert(document.cookie)" @controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer)) - assert_equal 'javascript:history.back()', url_for(:back) + assert_equal "javascript:history.back()", url_for(:back) end def test_url_for_with_invalid_referer - referer = 'THIS IS NOT A URL' + referer = "THIS IS NOT A URL" @controller = Struct.new(:request).new(Struct.new(:env).new("HTTP_REFERER" => referer)) - assert_equal 'javascript:history.back()', url_for(:back) + assert_equal "javascript:history.back()", url_for(:back) end def test_to_form_params_with_hash assert_equal( - [{ name: :name, value: 'David' }, { name: :nationality, value: 'Danish' }], - to_form_params(name: 'David', nationality: 'Danish') + [{ name: :name, value: "David" }, { name: :nationality, value: "Danish" }], + to_form_params(name: "David", nationality: "Danish") ) end def test_to_form_params_with_nested_hash assert_equal( - [{ name: 'country[name]', value: 'Denmark' }], - to_form_params(country: { name: 'Denmark' }) + [{ name: "country[name]", value: "Denmark" }], + to_form_params(country: { name: "Denmark" }) ) end def test_to_form_params_with_array_nested_in_hash assert_equal( - [{ name: 'countries[]', value: 'Denmark' }, { name: 'countries[]', value: 'Sweden' }], - to_form_params(countries: ['Denmark', 'Sweden']) + [{ name: "countries[]", value: "Denmark" }, { name: "countries[]", value: "Sweden" }], + to_form_params(countries: ["Denmark", "Sweden"]) ) end def test_to_form_params_with_namespace assert_equal( - [{ name: 'country[name]', value: 'Denmark' }], - to_form_params({name: 'Denmark'}, 'country') + [{ name: "country[name]", value: "Denmark" }], + to_form_params({name: "Denmark"}, "country") ) end @@ -122,11 +122,11 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_button_to_with_form_class - assert_dom_equal %{
}, button_to("Hello", "http://www.example.com", form_class: 'custom-class') + assert_dom_equal %{
}, button_to("Hello", "http://www.example.com", form_class: "custom-class") end def test_button_to_with_form_class_escapes - assert_dom_equal %{
}, button_to("Hello", "http://www.example.com", form_class: '') + assert_dom_equal %{
}, button_to("Hello", "http://www.example.com", form_class: "") end def test_button_to_with_query @@ -211,7 +211,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_button_to_with_block assert_dom_equal( %{
}, - button_to("http://www.example.com") { content_tag(:span, 'Hello') } + button_to("http://www.example.com") { content_tag(:span, "Hello") } ) end @@ -225,14 +225,14 @@ class UrlHelperTest < ActiveSupport::TestCase def test_button_to_with_nested_hash_params assert_dom_equal( %{
}, - button_to("Hello", "http://www.example.com", params: { foo: { bar: 'baz' } }) + button_to("Hello", "http://www.example.com", params: { foo: { bar: "baz" } }) ) end def test_button_to_with_nested_array_params assert_dom_equal( %{
}, - button_to("Hello", "http://www.example.com", params: { foo: ['bar'] }) + button_to("Hello", "http://www.example.com", params: { foo: ["bar"] }) ) end @@ -241,13 +241,13 @@ class UrlHelperTest < ActiveSupport::TestCase end def test_link_tag_without_host_option - assert_dom_equal(%{Test Link}, link_to('Test Link', url_hash)) + assert_dom_equal(%{Test Link}, link_to("Test Link", url_hash)) end def test_link_tag_with_host_option hash = hash_for(host: "www.example.com") expected = %{Test Link} - assert_dom_equal(expected, link_to('Test Link', hash)) + assert_dom_equal(expected, link_to("Test Link", hash)) end def test_link_tag_with_query @@ -264,12 +264,12 @@ class UrlHelperTest < ActiveSupport::TestCase env = {"HTTP_REFERER" => "http://www.example.com/referer"} @controller = Struct.new(:request).new(Struct.new(:env).new(env)) expected = %{go back} - assert_dom_equal expected, link_to('go back', :back) + assert_dom_equal expected, link_to("go back", :back) end def test_link_tag_with_back_and_no_referer @controller = Struct.new(:request).new(Struct.new(:env).new({})) - link = link_to('go back', :back) + link = link_to("go back", :back) assert_dom_equal %{go back}, link end @@ -329,7 +329,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_link_to_with_string_remote_in_non_html_options assert_dom_equal( %{Hello}, - link_to("Hello", hash_for('remote' => true), {}) + link_to("Hello", hash_for("remote" => true), {}) ) end @@ -350,14 +350,14 @@ class UrlHelperTest < ActiveSupport::TestCase def test_link_tag_using_delete_javascript_and_href assert_dom_equal( %{Destroy}, - link_to("Destroy", "http://www.example.com", method: :delete, href: '#') + link_to("Destroy", "http://www.example.com", method: :delete, href: "#") ) end def test_link_tag_using_post_javascript_and_rel assert_dom_equal( %{Hello}, - link_to("Hello", "http://www.example.com", method: :post, rel: 'example') + link_to("Hello", "http://www.example.com", method: :post, rel: "example") ) end @@ -371,24 +371,24 @@ class UrlHelperTest < ActiveSupport::TestCase def test_link_tag_using_delete_javascript_and_href_and_confirm assert_dom_equal( %{Destroy}, - link_to("Destroy", "http://www.example.com", method: :delete, href: '#', data: { confirm: "Are you serious?" }) + link_to("Destroy", "http://www.example.com", method: :delete, href: "#", data: { confirm: "Are you serious?" }) ) end def test_link_tag_with_block assert_dom_equal %{Example site}, - link_to('/') { content_tag(:span, 'Example site') } + link_to("/") { content_tag(:span, "Example site") } end def test_link_tag_with_block_and_html_options assert_dom_equal %{Example site}, - link_to('/', class: "special") { content_tag(:span, 'Example site') } + link_to("/", class: "special") { content_tag(:span, "Example site") } end def test_link_tag_using_block_and_hash assert_dom_equal( %{Example site}, - link_to(url_hash) { content_tag(:span, 'Example site') } + link_to(url_hash) { content_tag(:span, "Example site") } ) end @@ -480,19 +480,19 @@ class UrlHelperTest < ActiveSupport::TestCase def test_current_page_with_not_get_verb @request = request_for_url("/events", method: :post) - assert !current_page?('/events') + assert !current_page?("/events") end def test_current_page_with_escaped_params @request = request_for_url("/category/administra%c3%a7%c3%a3o") - assert current_page?(controller: 'foo', action: 'category', category: 'administração') + assert current_page?(controller: "foo", action: "category", category: "administração") end def test_current_page_with_escaped_params_with_different_encoding @request = request_for_url("/") @request.stub(:path, "/category/administra%c3%a7%c3%a3o".force_encoding(Encoding::ASCII_8BIT)) do - assert current_page?(:controller => 'foo', :action => 'category', category: 'administração') + assert current_page?(:controller => "foo", :action => "category", category: "administração") assert current_page?("http://www.example.com/category/administra%c3%a7%c3%a3o") end end @@ -500,7 +500,7 @@ class UrlHelperTest < ActiveSupport::TestCase def test_current_page_with_double_escaped_params @request = request_for_url("/category/administra%c3%a7%c3%a3o?callback_url=http%3a%2f%2fexample.com%2ffoo") - assert current_page?(controller: 'foo', action: 'category', category: 'administração', callback_url: 'http://example.com/foo') + assert current_page?(controller: "foo", action: "category", category: "administração", callback_url: "http://example.com/foo") end def test_current_page_with_trailing_slash @@ -527,7 +527,7 @@ class UrlHelperTest < ActiveSupport::TestCase @request = request_for_url("/?order=desc&page=1") assert_equal "Showing", - link_to_unless_current("Showing", hash_for(order: 'desc', page: '1')) + link_to_unless_current("Showing", hash_for(order: "desc", page: "1")) assert_equal "Showing", link_to_unless_current("Showing", "http://www.example.com/?order=desc&page=1") @@ -583,13 +583,13 @@ class UrlHelperTest < ActiveSupport::TestCase assert_dom_equal( %{My email}, - mail_to("me@example.com", "My email", cc: '', bcc: '', subject: "This is an example email", body: "This is the body of the message.") + mail_to("me@example.com", "My email", cc: "", bcc: "", subject: "This is an example email", body: "This is the body of the message.") ) end def test_mail_to_with_img assert_dom_equal %{}, - mail_to('feedback@example.com', raw('')) + mail_to("feedback@example.com", raw('')) end def test_mail_to_with_html_safe_string @@ -612,18 +612,18 @@ class UrlHelperTest < ActiveSupport::TestCase def test_mail_to_with_block assert_dom_equal %{Email me}, - mail_to('me@example.com') { content_tag(:span, 'Email me') } + mail_to("me@example.com") { content_tag(:span, "Email me") } end def test_mail_to_with_block_and_options assert_dom_equal %{Email me}, - mail_to('me@example.com', cc: "ccaddress@example.com", class: "special") { content_tag(:span, 'Email me') } + mail_to("me@example.com", cc: "ccaddress@example.com", class: "special") { content_tag(:span, "Email me") } end def test_mail_to_does_not_modify_html_options_hash - options = { class: 'special' } - mail_to 'me@example.com', 'ME!', options - assert_equal({ class: 'special' }, options) + options = { class: "special" } + mail_to "me@example.com", "ME!", options + assert_equal({ class: "special" }, options) end def protect_against_forgery? @@ -640,8 +640,8 @@ class UrlHelperTest < ActiveSupport::TestCase private def sort_query_string_params(uri) - path, qs = uri.split('?') - qs = qs.split('&').sort.join('&') if qs + path, qs = uri.split("?") + qs = qs.split("&").sort.join("&") if qs qs ? "#{path}?#{qs}" : path end end @@ -649,34 +649,34 @@ end class UrlHelperControllerTest < ActionController::TestCase class UrlHelperController < ActionController::Base test_routes do - get 'url_helper_controller_test/url_helper/show/:id', - to: 'url_helper_controller_test/url_helper#show', + get "url_helper_controller_test/url_helper/show/:id", + to: "url_helper_controller_test/url_helper#show", as: :show - get 'url_helper_controller_test/url_helper/profile/:name', - to: 'url_helper_controller_test/url_helper#show', + get "url_helper_controller_test/url_helper/profile/:name", + to: "url_helper_controller_test/url_helper#show", as: :profile - get 'url_helper_controller_test/url_helper/show_named_route', - to: 'url_helper_controller_test/url_helper#show_named_route', + get "url_helper_controller_test/url_helper/show_named_route", + to: "url_helper_controller_test/url_helper#show_named_route", as: :show_named_route ActiveSupport::Deprecation.silence do get "/:controller(/:action(/:id))" end - get 'url_helper_controller_test/url_helper/normalize_recall_params', + get "url_helper_controller_test/url_helper/normalize_recall_params", to: UrlHelperController.action(:normalize_recall), as: :normalize_recall_params - get '/url_helper_controller_test/url_helper/override_url_helper/default', - to: 'url_helper_controller_test/url_helper#override_url_helper', + get "/url_helper_controller_test/url_helper/override_url_helper/default", + to: "url_helper_controller_test/url_helper#override_url_helper", as: :override_url_helper end def show if params[:name] - render inline: 'ok' + render inline: "ok" else redirect_to profile_path(params[:id]) end @@ -691,23 +691,23 @@ class UrlHelperControllerTest < ActionController::TestCase end def nil_url_for - render inline: '<%= url_for(nil) %>' + render inline: "<%= url_for(nil) %>" end def normalize_recall_params - render inline: '<%= normalize_recall_params_path %>' + render inline: "<%= normalize_recall_params_path %>" end def recall_params_not_changed - render inline: '<%= url_for(action: :show_url_for) %>' + render inline: "<%= url_for(action: :show_url_for) %>" end def override_url_helper - render inline: '<%= override_url_helper_path %>' + render inline: "<%= override_url_helper_path %>" end def override_url_helper_path - '/url_helper_controller_test/url_helper/override_url_helper/override' + "/url_helper_controller_test/url_helper/override_url_helper/override" end helper_method :override_url_helper_path end @@ -716,58 +716,58 @@ class UrlHelperControllerTest < ActionController::TestCase def test_url_for_shows_only_path get :show_url_for - assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body + assert_equal "/url_helper_controller_test/url_helper/show_url_for", @response.body end def test_named_route_url_shows_host_and_path - get :show_named_route, params: { kind: 'url' } - assert_equal 'http://test.host/url_helper_controller_test/url_helper/show_named_route', + get :show_named_route, params: { kind: "url" } + assert_equal "http://test.host/url_helper_controller_test/url_helper/show_named_route", @response.body end def test_named_route_path_shows_only_path - get :show_named_route, params: { kind: 'path' } - assert_equal '/url_helper_controller_test/url_helper/show_named_route', @response.body + get :show_named_route, params: { kind: "path" } + assert_equal "/url_helper_controller_test/url_helper/show_named_route", @response.body end def test_url_for_nil_returns_current_path get :nil_url_for - assert_equal '/url_helper_controller_test/url_helper/nil_url_for', @response.body + assert_equal "/url_helper_controller_test/url_helper/nil_url_for", @response.body end def test_named_route_should_show_host_and_path_using_controller_default_url_options class << @controller def default_url_options - { host: 'testtwo.host' } + { host: "testtwo.host" } end end - get :show_named_route, params: { kind: 'url' } - assert_equal 'http://testtwo.host/url_helper_controller_test/url_helper/show_named_route', @response.body + get :show_named_route, params: { kind: "url" } + assert_equal "http://testtwo.host/url_helper_controller_test/url_helper/show_named_route", @response.body end def test_recall_params_should_be_normalized get :normalize_recall_params - assert_equal '/url_helper_controller_test/url_helper/normalize_recall_params', @response.body + assert_equal "/url_helper_controller_test/url_helper/normalize_recall_params", @response.body end def test_recall_params_should_not_be_changed get :recall_params_not_changed - assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body + assert_equal "/url_helper_controller_test/url_helper/show_url_for", @response.body end def test_recall_params_should_normalize_id - get :show, params: { id: '123' } + get :show, params: { id: "123" } assert_equal 302, @response.status - assert_equal 'http://test.host/url_helper_controller_test/url_helper/profile/123', @response.location + assert_equal "http://test.host/url_helper_controller_test/url_helper/profile/123", @response.location - get :show, params: { name: '123' } - assert_equal 'ok', @response.body + get :show, params: { name: "123" } + assert_equal "ok", @response.body end def test_url_helper_can_be_overridden get :override_url_helper - assert_equal '/url_helper_controller_test/url_helper/override_url_helper/override', @response.body + assert_equal "/url_helper_controller_test/url_helper/override_url_helper/override", @response.body end end -- cgit v1.2.3