client_side_validations 3.1.5 → 3.2.0.beta.1
Sign up to get free protection for your applications and to get access to all the features.
- data/client_side_validations.gemspec +1 -9
- data/lib/client_side_validations.rb +6 -2
- data/lib/client_side_validations/action_view/form_builder.rb +4 -2
- data/lib/client_side_validations/action_view/form_helper.rb +15 -7
- data/lib/client_side_validations/active_model.rb +5 -2
- data/lib/client_side_validations/active_record.rb +2 -1
- data/lib/client_side_validations/active_record/middleware.rb +15 -2
- data/lib/client_side_validations/active_record/uniqueness.rb +0 -1
- data/lib/client_side_validations/core_ext/regexp.rb +1 -1
- data/lib/client_side_validations/middleware.rb +40 -16
- data/lib/client_side_validations/version.rb +1 -1
- data/lib/generators/templates/client_side_validations/initializer.rb +0 -3
- data/vendor/assets/javascripts/rails.validations.js +135 -170
- metadata +22 -329
- data/lib/client_side_validations/formtastic.rb +0 -21
- data/lib/client_side_validations/mongo_mapper.rb +0 -9
- data/lib/client_side_validations/mongo_mapper/middleware.rb +0 -20
- data/lib/client_side_validations/mongo_mapper/uniqueness.rb +0 -29
- data/lib/client_side_validations/mongoid.rb +0 -9
- data/lib/client_side_validations/mongoid/format.rb +0 -10
- data/lib/client_side_validations/mongoid/length.rb +0 -24
- data/lib/client_side_validations/mongoid/middleware.rb +0 -20
- data/lib/client_side_validations/mongoid/presence.rb +0 -10
- data/lib/client_side_validations/mongoid/uniqueness.rb +0 -29
- data/lib/client_side_validations/simple_form.rb +0 -24
- data/lib/generators/templates/client_side_validations/README.rails.3.0 +0 -6
- data/test/action_view/cases/helper.rb +0 -176
- data/test/action_view/cases/test_helpers.rb +0 -635
- data/test/action_view/cases/test_legacy_helpers.rb +0 -217
- data/test/action_view/models.rb +0 -3
- data/test/action_view/models/comment.rb +0 -35
- data/test/action_view/models/post.rb +0 -35
- data/test/active_model/cases/helper.rb +0 -4
- data/test/active_model/cases/test_acceptance_validator.rb +0 -16
- data/test/active_model/cases/test_base.rb +0 -11
- data/test/active_model/cases/test_confirmation_validator.rb +0 -16
- data/test/active_model/cases/test_exclusion_validator.rb +0 -20
- data/test/active_model/cases/test_format_validator.rb +0 -21
- data/test/active_model/cases/test_inclusion_validator.rb +0 -21
- data/test/active_model/cases/test_length_validator.rb +0 -61
- data/test/active_model/cases/test_numericality_validator.rb +0 -46
- data/test/active_model/cases/test_presence_validator.rb +0 -16
- data/test/active_model/cases/test_validations.rb +0 -175
- data/test/active_model/models/person.rb +0 -17
- data/test/active_record/cases/helper.rb +0 -12
- data/test/active_record/cases/test_base.rb +0 -11
- data/test/active_record/cases/test_middleware.rb +0 -175
- data/test/active_record/cases/test_uniqueness_validator.rb +0 -56
- data/test/active_record/models/guid.rb +0 -7
- data/test/active_record/models/user.rb +0 -14
- data/test/base_helper.rb +0 -21
- data/test/core_ext/cases/test_core_ext.rb +0 -46
- data/test/formtastic/cases/helper.rb +0 -7
- data/test/formtastic/cases/test_form_builder.rb +0 -11
- data/test/formtastic/cases/test_form_helper.rb +0 -21
- data/test/generators/cases/test_generators.rb +0 -70
- data/test/javascript/config.ru +0 -3
- data/test/javascript/public/test/callbacks/elementAfter.js +0 -54
- data/test/javascript/public/test/callbacks/elementBefore.js +0 -54
- data/test/javascript/public/test/callbacks/elementFail.js +0 -70
- data/test/javascript/public/test/callbacks/elementPass.js +0 -70
- data/test/javascript/public/test/callbacks/formAfter.js +0 -45
- data/test/javascript/public/test/callbacks/formBefore.js +0 -45
- data/test/javascript/public/test/callbacks/formFail.js +0 -51
- data/test/javascript/public/test/callbacks/formPass.js +0 -50
- data/test/javascript/public/test/form_builders/validateForm.js +0 -66
- data/test/javascript/public/test/form_builders/validateFormtastic.js +0 -54
- data/test/javascript/public/test/form_builders/validateNestedForm.js +0 -66
- data/test/javascript/public/test/form_builders/validateSimpleForm.js +0 -57
- data/test/javascript/public/test/settings.js +0 -15
- data/test/javascript/public/test/validateElement.js +0 -179
- data/test/javascript/public/test/validators/acceptance.js +0 -42
- data/test/javascript/public/test/validators/confirmation.js +0 -25
- data/test/javascript/public/test/validators/exclusion.js +0 -41
- data/test/javascript/public/test/validators/format.js +0 -27
- data/test/javascript/public/test/validators/inclusion.js +0 -42
- data/test/javascript/public/test/validators/length.js +0 -76
- data/test/javascript/public/test/validators/numericality.js +0 -158
- data/test/javascript/public/test/validators/presence.js +0 -21
- data/test/javascript/public/test/validators/uniqueness.js +0 -107
- data/test/javascript/public/vendor/jquery.metadata.js +0 -122
- data/test/javascript/public/vendor/qunit.css +0 -196
- data/test/javascript/public/vendor/qunit.js +0 -1374
- data/test/javascript/server.rb +0 -84
- data/test/javascript/views/index.erb +0 -20
- data/test/javascript/views/layout.erb +0 -21
- data/test/middleware/cases/helper.rb +0 -7
- data/test/middleware/cases/test_middleware.rb +0 -8
- data/test/mongo_mapper/cases/helper.rb +0 -9
- data/test/mongo_mapper/cases/test_base.rb +0 -15
- data/test/mongo_mapper/cases/test_middleware.rb +0 -77
- data/test/mongo_mapper/cases/test_uniqueness_validator.rb +0 -55
- data/test/mongo_mapper/models/magazine.rb +0 -11
- data/test/mongoid/cases/helper.rb +0 -12
- data/test/mongoid/cases/test_base.rb +0 -15
- data/test/mongoid/cases/test_format_validator.rb +0 -21
- data/test/mongoid/cases/test_length_validator.rb +0 -60
- data/test/mongoid/cases/test_middleware.rb +0 -77
- data/test/mongoid/cases/test_presence_validator.rb +0 -16
- data/test/mongoid/cases/test_uniqueness_validator.rb +0 -54
- data/test/mongoid/models/book.rb +0 -12
- data/test/simple_form/cases/helper.rb +0 -5
- data/test/simple_form/cases/test_form_builder.rb +0 -14
- data/test/simple_form/cases/test_form_helper.rb +0 -24
- data/test/test_loader.rb +0 -6
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'mongoid/cases/test_base'
|
2
|
-
|
3
|
-
class Mongoid::UniqunessValidatorTest < ClientSideValidations::MongoidTestBase
|
4
|
-
|
5
|
-
def test_presence_client_side_hash
|
6
|
-
expected_hash = { :message => "can't be blank" }
|
7
|
-
assert_equal expected_hash, PresenceValidator.new(:attributes => [:name]).client_side_hash(@book, :age)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_presence_client_side_hash_with_custom_message
|
11
|
-
expected_hash = { :message => "is required" }
|
12
|
-
assert_equal expected_hash, PresenceValidator.new(:attributes => [:name], :message => "is required").client_side_hash(@book, :age)
|
13
|
-
end
|
14
|
-
|
15
|
-
end
|
16
|
-
|
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'mongoid/cases/test_base'
|
2
|
-
|
3
|
-
class Mongoid::UniqunessValidatorTest < ClientSideValidations::MongoidTestBase
|
4
|
-
|
5
|
-
def test_uniqueness_client_side_hash
|
6
|
-
expected_hash = { :message => "is already taken" }
|
7
|
-
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name]).client_side_hash(@book, :age)
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_uniqueness_client_side_hash_with_custom_message
|
11
|
-
expected_hash = { :message => "is not available" }
|
12
|
-
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name], :message => "is not available").client_side_hash(@book, :age)
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_uniqueness_client_side_hash_with_id
|
16
|
-
@book.stubs(:new_record?).returns(false)
|
17
|
-
@book.stubs(:id).returns(1)
|
18
|
-
expected_hash = { :message => "is already taken", :id => 1 }
|
19
|
-
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name]).client_side_hash(@book, :age)
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_uniqueness_client_side_hash_with_single_scope_item
|
23
|
-
@book.stubs(:author_email).returns("test@test.com")
|
24
|
-
expected_hash = { :message => "is already taken", :scope => {:author_email => "test@test.com"} }
|
25
|
-
result_hash = UniquenessValidator.new(:attributes => [:author_name], :scope => :author_email).client_side_hash(@book, :author_name)
|
26
|
-
assert_equal expected_hash, result_hash
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_uniqueness_client_side_hash_with_multiple_scope_items
|
30
|
-
@book.stubs(:age).returns(30)
|
31
|
-
@book.stubs(:author_email).returns("test@test.com")
|
32
|
-
expected_hash = { :message => "is already taken", :scope => {:age => 30, :author_email => "test@test.com"} }
|
33
|
-
result_hash = UniquenessValidator.new(:attributes => [:author_name], :scope => [:age, :author_email]).client_side_hash(@book, :author_name)
|
34
|
-
assert_equal expected_hash, result_hash
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_uniqueness_client_side_hash_with_empty_scope_array
|
38
|
-
expected_hash = { :message => "is already taken" }
|
39
|
-
result_hash = UniquenessValidator.new(:attributes => [:author_name], :scope => []).client_side_hash(@book, :author_name)
|
40
|
-
assert_equal expected_hash, result_hash
|
41
|
-
end
|
42
|
-
|
43
|
-
def test_uniqueness_client_side_hash_when_nested_module
|
44
|
-
@book = MongoidTestModule::Book2.new
|
45
|
-
expected_hash = { :message => "is already taken", :class => 'mongoid_test_module/book2' }
|
46
|
-
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name]).client_side_hash(@book, :age)
|
47
|
-
end
|
48
|
-
|
49
|
-
def test_uniqueness_client_side_hash_with_allow_blank
|
50
|
-
expected_hash = { :message => "is already taken", :allow_blank => true }
|
51
|
-
assert_equal expected_hash, UniquenessValidator.new(:attributes => [:name], :allow_blank => true).client_side_hash(@book, :age)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
data/test/mongoid/models/book.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'simple_form/cases/helper'
|
2
|
-
|
3
|
-
class ClientSideValidations::SimpleForm::FormBuilderTest < Test::Unit::TestCase
|
4
|
-
def test_client_side_form_js_hash
|
5
|
-
expected = {
|
6
|
-
:type => 'SimpleForm::FormBuilder',
|
7
|
-
:error_class => :error,
|
8
|
-
:error_tag => :span,
|
9
|
-
:wrapper_error_class => :field_with_errors,
|
10
|
-
:wrapper_tag => :div
|
11
|
-
}
|
12
|
-
assert_equal expected, SimpleForm::FormBuilder.client_side_form_settings(nil, nil)
|
13
|
-
end
|
14
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'action_view/cases/helper'
|
2
|
-
require 'middleware/cases/helper'
|
3
|
-
require 'simple_form/cases/helper'
|
4
|
-
|
5
|
-
class ClientSideValidations::SimpleForm::FormHelperTest < ActionView::TestCase
|
6
|
-
include ActionViewTestSetup
|
7
|
-
include SimpleForm::ActionViewExtensions::FormHelper
|
8
|
-
|
9
|
-
def client_side_form_settings_helper
|
10
|
-
""
|
11
|
-
end
|
12
|
-
|
13
|
-
def test_simple_form_for
|
14
|
-
ActionView::TestCase::TestController.any_instance.stubs(:action_name).returns('edit')
|
15
|
-
simple_form_for(@post, :validate => true) do |f|
|
16
|
-
concat f.input(:cost)
|
17
|
-
end
|
18
|
-
|
19
|
-
expected = %{<form accept-charset="UTF-8" action="/posts/123" class="simple_form post" data-validate="true" id="edit_post_123" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /><input name="_method" type="hidden" value="put" /></div><div class="input string required"><label class="string required" for="post_cost"><abbr title="required">*</abbr> Cost</label><input class="string required" data-validate="true" id="post_cost" name="post[cost]" required="required" size="50" type="text" /></div></form><script>window['edit_post_123'] = {"type":"SimpleForm::FormBuilder","error_class":"error","error_tag":"span","wrapper_error_class":"field_with_errors","wrapper_tag":"div","validators":{"post[cost]":{"presence":{"message":"can't be blank"}}}};</script>}
|
20
|
-
assert_equal expected, output_buffer, "\n\n *** If you're running Ruby 1.8 and this test fails is is most likely due to 1.8's lack of insertion order persistence with Hashes ***\n"
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|