Skip to content

Commit

Permalink
Merge pull request #779 from DavyJonesLocker/feature/jquery-3_5_0-com…
Browse files Browse the repository at this point in the history
…patibility

Feature/jquery 3 5 0 compatibility
  • Loading branch information
tagliala committed Apr 11, 2020
2 parents ef3126c + 8a3600e commit 17f3be4
Show file tree
Hide file tree
Showing 29 changed files with 92 additions and 95 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,11 @@
# Changelog

## 16.2.0 / 2020-04-10

* [FEATURE] Add jQuery 3.5.0 compatibility ([#779](https://github.com/DavyJonesLocker/client_side_validations/pull/779))
* [ENHANCEMENT] Test against latest Ruby versions
* [ENHANCEMENT] Update development dependencies

## 16.1.1 / 2020-03-20

* [BUGFIX] Fix custom validators for nested attributes ([#778](https://github.com/DavyJonesLocker/client_side_validations/pull/778))
Expand Down
2 changes: 1 addition & 1 deletion dist/client-side-validations.esm.js
@@ -1,5 +1,5 @@
/*!
* Client Side Validations JS - v0.1.2 (https://github.com/DavyJonesLocker/client_side_validations)
* Client Side Validations JS - v0.1.3 (https://github.com/DavyJonesLocker/client_side_validations)
* Copyright (c) 2020 Geremia Taglialatela, Brian Cardarella
* Licensed under MIT (https://opensource.org/licenses/mit-license.php)
*/
Expand Down
2 changes: 1 addition & 1 deletion dist/client-side-validations.js
@@ -1,5 +1,5 @@
/*!
* Client Side Validations JS - v0.1.2 (https://github.com/DavyJonesLocker/client_side_validations)
* Client Side Validations JS - v0.1.3 (https://github.com/DavyJonesLocker/client_side_validations)
* Copyright (c) 2020 Geremia Taglialatela, Brian Cardarella
* Licensed under MIT (https://opensource.org/licenses/mit-license.php)
*/
Expand Down
4 changes: 2 additions & 2 deletions lib/client_side_validations/action_view/form_builder.rb
Expand Up @@ -25,8 +25,8 @@ def #{selector}(method, options = {})
def client_side_form_settings(_options, form_helper)
{
type: self.class.to_s,
input_tag: form_helper.class.field_error_proc.call(%(<span id="input_tag" />), Struct.new(:error_message, :tag_id).new([], '')),
label_tag: form_helper.class.field_error_proc.call(%(<label id="label_tag" />), Struct.new(:error_message, :tag_id).new([], ''))
input_tag: form_helper.class.field_error_proc.call(%(<span id="input_tag"></span>), Struct.new(:error_message, :tag_id).new([], '')),
label_tag: form_helper.class.field_error_proc.call(%(<label id="label_tag"></label>), Struct.new(:error_message, :tag_id).new([], ''))
}
end

Expand Down
2 changes: 1 addition & 1 deletion lib/client_side_validations/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ClientSideValidations
VERSION = '16.1.1'
VERSION = '16.2.0'
end
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -53,7 +53,7 @@
"/vendor/"
]
},
"version": "0.1.2",
"version": "0.1.3",
"directories": {
"lib": "lib",
"test": "test"
Expand Down
8 changes: 8 additions & 0 deletions test/action_view/cases/helper.rb
Expand Up @@ -189,6 +189,14 @@ def whole_form_with(action = 'http://www.example.com', options = nil)
form_with_text(action, id, html_class, local, (validators || no_validate), file) + snowman(method) + (contents || '') + '</form>'
end

def client_side_form_settings_helper
{
type: 'ActionView::Helpers::FormBuilder',
input_tag: %(<span id="input_tag"></span>),
label_tag: %(<label id="label_tag"></label>)
}
end

def csv_data_attribute(validators)
{
html_settings: client_side_form_settings_helper,
Expand Down
10 changes: 1 addition & 9 deletions test/action_view/cases/test_form_for_helpers.rb
Expand Up @@ -3,20 +3,12 @@
require 'action_view/cases/helper'

module ClientSideValidations
class ActionViewHelpersTest < ::ActionView::TestCase
class FormForActionViewHelpersTest < ::ActionView::TestCase
include ::ActionViewTestSetup

cattr_accessor :field_error_proc
@@field_error_proc = proc { |html_tag, _| html_tag }

def client_side_form_settings_helper
{
type: 'ActionView::Helpers::FormBuilder',
input_tag: %(<span id="input_tag" />),
label_tag: %(<label id="label_tag" />)
}
end

def test_text_field
form_for(@post, validate: true) do |f|
concat f.text_field(:cost)
Expand Down
10 changes: 1 addition & 9 deletions test/action_view/cases/test_form_with_helpers.rb
Expand Up @@ -4,20 +4,12 @@

if ::ActionView::Helpers::FormHelper.method_defined?(:form_with)
module ClientSideValidations
class ActionViewHelpersTest < ::ActionView::TestCase
class FormWithActionViewHelpersTest < ::ActionView::TestCase
include ::ActionViewTestSetup

cattr_accessor :field_error_proc
@@field_error_proc = proc { |html_tag, _| html_tag }

def client_side_form_settings_helper
{
type: 'ActionView::Helpers::FormBuilder',
input_tag: %(<span id="input_tag" />),
label_tag: %(<label id="label_tag" />)
}
end

def test_form_with_without_block
form_with(model: @post, validate: true)

Expand Down
2 changes: 1 addition & 1 deletion test/action_view/cases/test_legacy_form_for_helpers.rb
Expand Up @@ -3,7 +3,7 @@
require 'action_view/cases/helper'

module ClientSideValidations
class LegacyActionViewHelpersTest < ::ActionView::TestCase
class LegacyFormForActionViewHelpersTest < ::ActionView::TestCase
include ::ActionViewTestSetup

def test_text_field
Expand Down
2 changes: 1 addition & 1 deletion test/action_view/cases/test_legacy_form_with_helpers.rb
Expand Up @@ -4,7 +4,7 @@

if ::ActionView::Helpers::FormHelper.method_defined?(:form_with)
module ClientSideValidations
class LegacyActionViewHelpersTest < ::ActionView::TestCase
class LegacyFormWithActionViewHelpersTest < ::ActionView::TestCase
include ::ActionViewTestSetup

def automatic_id(id)
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/elementAfter.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Element Validate After Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/elementBefore.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Element Validate Before Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { '{presence': [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/elementFail.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Element Validate Fail Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/elementPass.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Element Validate Pass Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/formAfter.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Form Validate After Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/formBefore.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Form Validate Before Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/formFail.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Form Validate Fail Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/callbacks/formPass.js
Expand Up @@ -3,15 +3,15 @@ QUnit.module('Form Validate Pass Callback', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<span id="result" />'))
.append($('<form />', {
.append($('<span id="result">'))
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down
8 changes: 4 additions & 4 deletions test/javascript/public/test/form_builders/validateForm.js
Expand Up @@ -3,14 +3,14 @@ QUnit.module('Validate Form', {
dataCsv = {
html_settings: {
type: 'ActionView::Helpers::FormBuilder',
input_tag: '<div class="field_with_errors"><span id="input_tag" /><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag" /></div>'
input_tag: '<div class="field_with_errors"><span id="input_tag"></span><label for="user_name" class="message"></label></div>',
label_tag: '<div class="field_with_errors"><label id="label_tag"></label></div>'
},
validators: { 'user[name]': { presence: [{ message: 'must be present' }] } }
}

$('#qunit-fixture')
.append($('<form />', {
.append($('<form>', {
action: '/users',
'data-client-side-validations': JSON.stringify(dataCsv),
method: 'post',
Expand Down Expand Up @@ -82,7 +82,7 @@ QUnit.test('Ensure ajax:beforeSend is not from a bubbled event (async)', functio
var input = form.find('input#user_name')

form
.append('<a />')
.append('<a>')
.find('a').trigger('ajax:beforeSend')

setTimeout(function () {
Expand Down
4 changes: 2 additions & 2 deletions test/javascript/public/test/settings.js
@@ -1,7 +1,7 @@
QUnit.config.urlConfig.push({
id: 'jquery',
label: 'jQuery version',
value: ['3.4.1', '3.4.1.slim', '3.4.0', '3.4.0.slim', '3.3.1', '3.3.1.slim', '3.2.1', '3.2.1.slim', '3.1.1', '3.1.1.slim', '3.0.0', '3.0.0.slim', '2.2.4', '2.1.4', '2.0.3', '1.12.4', '1.11.3'],
value: ['3.5.0', '3.5.0.slim', '3.4.1', '3.4.1.slim', '3.3.1', '3.3.1.slim', '3.2.1', '3.2.1.slim', '3.1.1', '3.1.1.slim', '3.0.0', '3.0.0.slim', '2.2.4', '2.1.4', '2.0.3', '1.12.4', '1.11.3'],
tooltip: 'What jQuery Core version to test against'
})

Expand All @@ -13,7 +13,7 @@ $(document).on('submit', function (e) {
var form = $(e.target)
var action = form.attr('action')
var name = 'form-frame' + jQuery.guid++
var iframe = $('<iframe name="' + name + '" />')
var iframe = $('<iframe>', { name: name })

if (action && action.indexOf('iframe') < 0) form.attr('action', action + '?iframe=true')
form.attr('target', name)
Expand Down

0 comments on commit 17f3be4

Please sign in to comment.