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.
Files changed (105) hide show
  1. data/client_side_validations.gemspec +1 -9
  2. data/lib/client_side_validations.rb +6 -2
  3. data/lib/client_side_validations/action_view/form_builder.rb +4 -2
  4. data/lib/client_side_validations/action_view/form_helper.rb +15 -7
  5. data/lib/client_side_validations/active_model.rb +5 -2
  6. data/lib/client_side_validations/active_record.rb +2 -1
  7. data/lib/client_side_validations/active_record/middleware.rb +15 -2
  8. data/lib/client_side_validations/active_record/uniqueness.rb +0 -1
  9. data/lib/client_side_validations/core_ext/regexp.rb +1 -1
  10. data/lib/client_side_validations/middleware.rb +40 -16
  11. data/lib/client_side_validations/version.rb +1 -1
  12. data/lib/generators/templates/client_side_validations/initializer.rb +0 -3
  13. data/vendor/assets/javascripts/rails.validations.js +135 -170
  14. metadata +22 -329
  15. data/lib/client_side_validations/formtastic.rb +0 -21
  16. data/lib/client_side_validations/mongo_mapper.rb +0 -9
  17. data/lib/client_side_validations/mongo_mapper/middleware.rb +0 -20
  18. data/lib/client_side_validations/mongo_mapper/uniqueness.rb +0 -29
  19. data/lib/client_side_validations/mongoid.rb +0 -9
  20. data/lib/client_side_validations/mongoid/format.rb +0 -10
  21. data/lib/client_side_validations/mongoid/length.rb +0 -24
  22. data/lib/client_side_validations/mongoid/middleware.rb +0 -20
  23. data/lib/client_side_validations/mongoid/presence.rb +0 -10
  24. data/lib/client_side_validations/mongoid/uniqueness.rb +0 -29
  25. data/lib/client_side_validations/simple_form.rb +0 -24
  26. data/lib/generators/templates/client_side_validations/README.rails.3.0 +0 -6
  27. data/test/action_view/cases/helper.rb +0 -176
  28. data/test/action_view/cases/test_helpers.rb +0 -635
  29. data/test/action_view/cases/test_legacy_helpers.rb +0 -217
  30. data/test/action_view/models.rb +0 -3
  31. data/test/action_view/models/comment.rb +0 -35
  32. data/test/action_view/models/post.rb +0 -35
  33. data/test/active_model/cases/helper.rb +0 -4
  34. data/test/active_model/cases/test_acceptance_validator.rb +0 -16
  35. data/test/active_model/cases/test_base.rb +0 -11
  36. data/test/active_model/cases/test_confirmation_validator.rb +0 -16
  37. data/test/active_model/cases/test_exclusion_validator.rb +0 -20
  38. data/test/active_model/cases/test_format_validator.rb +0 -21
  39. data/test/active_model/cases/test_inclusion_validator.rb +0 -21
  40. data/test/active_model/cases/test_length_validator.rb +0 -61
  41. data/test/active_model/cases/test_numericality_validator.rb +0 -46
  42. data/test/active_model/cases/test_presence_validator.rb +0 -16
  43. data/test/active_model/cases/test_validations.rb +0 -175
  44. data/test/active_model/models/person.rb +0 -17
  45. data/test/active_record/cases/helper.rb +0 -12
  46. data/test/active_record/cases/test_base.rb +0 -11
  47. data/test/active_record/cases/test_middleware.rb +0 -175
  48. data/test/active_record/cases/test_uniqueness_validator.rb +0 -56
  49. data/test/active_record/models/guid.rb +0 -7
  50. data/test/active_record/models/user.rb +0 -14
  51. data/test/base_helper.rb +0 -21
  52. data/test/core_ext/cases/test_core_ext.rb +0 -46
  53. data/test/formtastic/cases/helper.rb +0 -7
  54. data/test/formtastic/cases/test_form_builder.rb +0 -11
  55. data/test/formtastic/cases/test_form_helper.rb +0 -21
  56. data/test/generators/cases/test_generators.rb +0 -70
  57. data/test/javascript/config.ru +0 -3
  58. data/test/javascript/public/test/callbacks/elementAfter.js +0 -54
  59. data/test/javascript/public/test/callbacks/elementBefore.js +0 -54
  60. data/test/javascript/public/test/callbacks/elementFail.js +0 -70
  61. data/test/javascript/public/test/callbacks/elementPass.js +0 -70
  62. data/test/javascript/public/test/callbacks/formAfter.js +0 -45
  63. data/test/javascript/public/test/callbacks/formBefore.js +0 -45
  64. data/test/javascript/public/test/callbacks/formFail.js +0 -51
  65. data/test/javascript/public/test/callbacks/formPass.js +0 -50
  66. data/test/javascript/public/test/form_builders/validateForm.js +0 -66
  67. data/test/javascript/public/test/form_builders/validateFormtastic.js +0 -54
  68. data/test/javascript/public/test/form_builders/validateNestedForm.js +0 -66
  69. data/test/javascript/public/test/form_builders/validateSimpleForm.js +0 -57
  70. data/test/javascript/public/test/settings.js +0 -15
  71. data/test/javascript/public/test/validateElement.js +0 -179
  72. data/test/javascript/public/test/validators/acceptance.js +0 -42
  73. data/test/javascript/public/test/validators/confirmation.js +0 -25
  74. data/test/javascript/public/test/validators/exclusion.js +0 -41
  75. data/test/javascript/public/test/validators/format.js +0 -27
  76. data/test/javascript/public/test/validators/inclusion.js +0 -42
  77. data/test/javascript/public/test/validators/length.js +0 -76
  78. data/test/javascript/public/test/validators/numericality.js +0 -158
  79. data/test/javascript/public/test/validators/presence.js +0 -21
  80. data/test/javascript/public/test/validators/uniqueness.js +0 -107
  81. data/test/javascript/public/vendor/jquery.metadata.js +0 -122
  82. data/test/javascript/public/vendor/qunit.css +0 -196
  83. data/test/javascript/public/vendor/qunit.js +0 -1374
  84. data/test/javascript/server.rb +0 -84
  85. data/test/javascript/views/index.erb +0 -20
  86. data/test/javascript/views/layout.erb +0 -21
  87. data/test/middleware/cases/helper.rb +0 -7
  88. data/test/middleware/cases/test_middleware.rb +0 -8
  89. data/test/mongo_mapper/cases/helper.rb +0 -9
  90. data/test/mongo_mapper/cases/test_base.rb +0 -15
  91. data/test/mongo_mapper/cases/test_middleware.rb +0 -77
  92. data/test/mongo_mapper/cases/test_uniqueness_validator.rb +0 -55
  93. data/test/mongo_mapper/models/magazine.rb +0 -11
  94. data/test/mongoid/cases/helper.rb +0 -12
  95. data/test/mongoid/cases/test_base.rb +0 -15
  96. data/test/mongoid/cases/test_format_validator.rb +0 -21
  97. data/test/mongoid/cases/test_length_validator.rb +0 -60
  98. data/test/mongoid/cases/test_middleware.rb +0 -77
  99. data/test/mongoid/cases/test_presence_validator.rb +0 -16
  100. data/test/mongoid/cases/test_uniqueness_validator.rb +0 -54
  101. data/test/mongoid/models/book.rb +0 -12
  102. data/test/simple_form/cases/helper.rb +0 -5
  103. data/test/simple_form/cases/test_form_builder.rb +0 -14
  104. data/test/simple_form/cases/test_form_helper.rb +0 -24
  105. 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
-
@@ -1,12 +0,0 @@
1
- class Book
2
- include Mongoid::Document
3
-
4
- field :age, :type => Integer
5
- field :author_name, :type => String
6
- field :author_email, :type => String
7
- end
8
-
9
- module MongoidTestModule
10
- class Book2 < Book; end
11
- end
12
-
@@ -1,5 +0,0 @@
1
- require 'action_view'
2
- require 'action_controller/railtie'
3
- require 'rails'
4
- require 'simple_form'
5
- require 'client_side_validations/simple_form'
@@ -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="&#x2713;" /><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
-
data/test/test_loader.rb DELETED
@@ -1,6 +0,0 @@
1
- # Sanity check to make sure the entire library loads OK
2
-
3
- require 'base_helper'
4
- require 'client_side_validations'
5
- require 'client_side_validations/files'
6
- require 'client_side_validations/version'