Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/update dependencies #926

Merged
merged 2 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ Metrics/PerceivedComplexity:
Minitest/MultipleAssertions:
Enabled: false

# FIXME: DavyJonesLocker/client_side_validations#927
Minitest/NonExecutableTestMethod:
Enabled: false

Rails/ApplicationRecord:
Exclude:
- 'test/**/*'
Expand Down
86 changes: 44 additions & 42 deletions test/action_view/cases/test_form_for_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
86 changes: 44 additions & 42 deletions test/action_view/cases/test_form_with_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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