From 2e86cb3e45557ef2943847103856a7ac754515e1 Mon Sep 17 00:00:00 2001 From: Geremia Taglialatela Date: Sun, 24 Dec 2023 17:09:20 +0100 Subject: [PATCH] Run tests that were skipped by mistake Fix Minitest/NonExecutableTestMethod --- .rubocop.yml | 4 - .../cases/test_form_for_helpers.rb | 86 ++++++++++--------- .../cases/test_form_with_helpers.rb | 86 ++++++++++--------- 3 files changed, 88 insertions(+), 88 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index b61c60d8..e842f0b7 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -62,10 +62,6 @@ Metrics/PerceivedComplexity: Minitest/MultipleAssertions: Enabled: false -# FIXME: DavyJonesLocker/client_side_validations#927 -Minitest/NonExecutableTestMethod: - Enabled: false - Rails/ApplicationRecord: Exclude: - 'test/**/*' diff --git a/test/action_view/cases/test_form_for_helpers.rb b/test/action_view/cases/test_form_for_helpers.rb index 61479c78..1f811377 100644 --- a/test/action_view/cases/test_form_for_helpers.rb +++ b/test/action_view/cases/test_form_for_helpers.rb @@ -647,61 +647,63 @@ def test_number_format_with_locale assert_dom_equal expected, output_buffer end - end - def test_field_with_format_a - assert_field_with_format_has_source(:a, 'a') - end + def test_field_with_format_a + assert_field_with_format_has_source(:a, 'a') + end - def test_field_with_format_backslash - assert_field_with_format_has_source(:backslash, '\\\\') - end + def test_field_with_format_backslash + assert_field_with_format_has_source(:backslash, '\\\\') + end - def test_field_with_format_space - # regression test for issue #460 - assert_field_with_format_has_source(:space, ' ') - end + def test_field_with_format_space + # regression test for issue #460 + assert_field_with_format_has_source(:space, ' ') + end - def test_field_with_format_escaped_space - assert_field_with_format_has_source(:escaped_space, '\\ ') - end + def test_field_with_format_escaped_space + assert_field_with_format_has_source(:escaped_space, '\\ ') + end - def test_field_with_format_ascii_escape - assert_field_with_format_has_source(:ascii_escape, '\\x41') - end + def test_field_with_format_ascii_escape + assert_field_with_format_has_source(:ascii_escape, '\\x41') + end - def test_field_with_format_unicode_escape - assert_field_with_format_has_source(:unicode_escape, '\\u263A') - end + def test_field_with_format_unicode_escape + assert_field_with_format_has_source(:unicode_escape, '\\u263A') + end - def test_field_with_format_unicode_literal - assert_field_with_format_has_source(:unicode_literal, '☺') - end + def test_field_with_format_unicode_literal + assert_field_with_format_has_source(:unicode_literal, '☺') + end - def test_field_with_format_newline_escape - assert_field_with_format_has_source(:newline_escape, '\\n') - end + def test_field_with_format_newline_escape + assert_field_with_format_has_source(:newline_escape, '\\n') + end - def test_field_with_format_newline_literal - assert_field_with_format_has_source(:newline_literal, '\\n') - end + def test_field_with_format_newline_literal + assert_field_with_format_has_source(:newline_literal, '\\n') + end - def test_field_with_format_devise_email - assert_field_with_format_has_source(:devise_email, '^[^@\\s]+@([^@\\s]+\\.)+[^@\\W]+$') - end + def test_field_with_format_devise_email + assert_field_with_format_has_source(:devise_email, '^[^@\\s]+@([^@\\s]+\\.)+[^@\\W]+$') + end - def assert_field_with_format_has_source(field, expected_source) - form_for(@format_thing, validate: true) { |f| concat(f.text_field(field)) } + private - validators = { - "format_thing[#{field}]" => { format: [{ message: 'is invalid', with: - { source: expected_source, options: '' } }] } - } + def assert_field_with_format_has_source(field, expected_source) + form_for(@format_thing, validate: true) { |f| concat(f.text_field(field)) } - expected = whole_form_for('/format_things', 'new_format_thing', 'new_format_thing', validators: validators) do - form_field('input', "format_thing_#{field}", "format_thing[#{field}]", 'text') - end + validators = { + "format_thing[#{field}]" => { format: [{ message: 'is invalid', with: + { source: expected_source, options: '' } }] } + } - assert_dom_equal expected, output_buffer + expected = whole_form_for('/format_things', 'new_format_thing', 'new_format_thing', validators: validators) do + form_field('input', id: "format_thing_#{field}", name: "format_thing[#{field}]", type: 'text') + end + + assert_dom_equal expected, output_buffer + end end end diff --git a/test/action_view/cases/test_form_with_helpers.rb b/test/action_view/cases/test_form_with_helpers.rb index c4fb7c79..c0a4b703 100644 --- a/test/action_view/cases/test_form_with_helpers.rb +++ b/test/action_view/cases/test_form_with_helpers.rb @@ -646,62 +646,64 @@ def test_form_with_number_format_with_locale assert_dom_equal expected, output_buffer end - end - def test_form_with_field_with_format_a - assert_field_with_format_has_source(:a, 'a') - end + def test_form_with_field_with_format_a + assert_field_with_format_has_source(:a, 'a') + end - def test_form_with_field_with_format_backslash - assert_field_with_format_has_source(:backslash, '\\\\') - end + def test_form_with_field_with_format_backslash + assert_field_with_format_has_source(:backslash, '\\\\') + end - def test_form_with_field_with_format_space - # regression test for issue #460 - assert_field_with_format_has_source(:space, ' ') - end + def test_form_with_field_with_format_space + # regression test for issue #460 + assert_field_with_format_has_source(:space, ' ') + end - def test_form_with_field_with_format_escaped_space - assert_field_with_format_has_source(:escaped_space, '\\ ') - end + def test_form_with_field_with_format_escaped_space + assert_field_with_format_has_source(:escaped_space, '\\ ') + end - def test_form_with_field_with_format_ascii_escape - assert_field_with_format_has_source(:ascii_escape, '\\x41') - end + def test_form_with_field_with_format_ascii_escape + assert_field_with_format_has_source(:ascii_escape, '\\x41') + end - def test_form_with_field_with_format_unicode_escape - assert_field_with_format_has_source(:unicode_escape, '\\u263A') - end + def test_form_with_field_with_format_unicode_escape + assert_field_with_format_has_source(:unicode_escape, '\\u263A') + end - def test_form_with_field_with_format_unicode_literal - assert_field_with_format_has_source(:unicode_literal, '☺') - end + def test_form_with_field_with_format_unicode_literal + assert_field_with_format_has_source(:unicode_literal, '☺') + end - def test_form_with_field_with_format_newline_escape - assert_field_with_format_has_source(:newline_escape, '\\n') - end + def test_form_with_field_with_format_newline_escape + assert_field_with_format_has_source(:newline_escape, '\\n') + end - def test_form_with_field_with_format_newline_literal - assert_field_with_format_has_source(:newline_literal, '\\n') - end + def test_form_with_field_with_format_newline_literal + assert_field_with_format_has_source(:newline_literal, '\\n') + end - def test_form_with_field_with_format_devise_email - assert_field_with_format_has_source(:devise_email, '^[^@\\s]+@([^@\\s]+\\.)+[^@\\W]+$') - end + def test_form_with_field_with_format_devise_email + assert_field_with_format_has_source(:devise_email, '^[^@\\s]+@([^@\\s]+\\.)+[^@\\W]+$') + end - def assert_field_with_format_has_source(field, expected_source) - form_with(model: @format_thing, validate: true) { |f| concat(f.text_field(field)) } + private - validators = { - "format_thing[#{field}]" => { format: [{ message: 'is invalid', with: - { source: expected_source, options: '' } }] } - } + def assert_field_with_format_has_source(field, expected_source) + form_with(model: @format_thing, validate: true) { |f| concat(f.text_field(field)) } - expected = whole_form_with('/format_things', validators: validators) do - form_field('input', "format_thing_#{field}", "format_thing[#{field}]", 'text') - end + validators = { + "format_thing[#{field}]" => { format: [{ message: 'is invalid', with: + { source: expected_source, options: '' } }] } + } + + expected = whole_form_with('/format_things', validators: validators) do + form_field('input', id: "format_thing_#{field}", name: "format_thing[#{field}]", type: 'text') + end - assert_dom_equal expected, output_buffer + assert_dom_equal expected, output_buffer + end end end end