activevalidators 1.7.0 → 1.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/active_validators/version.rb +1 -1
- data/lib/activevalidators.rb +2 -0
- data/test/test_helper.rb +1 -1
- data/test/validations/date_test.rb +16 -0
- metadata +6 -4
data/lib/activevalidators.rb
CHANGED
@@ -10,6 +10,8 @@ module ActiveModel
|
|
10
10
|
require "active_model/validations/#{validator_name}_validator"
|
11
11
|
end
|
12
12
|
|
13
|
+
require 'date_validator'
|
14
|
+
|
13
15
|
#Defines methods like validates_credit_card
|
14
16
|
module HelperMethods
|
15
17
|
ActiveModel::Validations.activevalidators.each do |validator|
|
data/test/test_helper.rb
CHANGED
@@ -21,7 +21,7 @@ class TestRecord
|
|
21
21
|
include ActiveModel::Validations
|
22
22
|
attr_accessor :ip, :url, :slug, :responder, :global_condition,
|
23
23
|
:local_condition, :phone, :email, :card, :password, :twitter_username,
|
24
|
-
:postal_code, :carrier, :tracking_number
|
24
|
+
:postal_code, :carrier, :tracking_number, :start_date, :end_date
|
25
25
|
|
26
26
|
def initialize(attrs = {})
|
27
27
|
attrs.each_pair { |k,v| send("#{k}=", v) }
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# ActiveValidators relies on another gem called "date_validator" edited
|
4
|
+
# by the fine folks at Codegram.
|
5
|
+
#
|
6
|
+
# If you wanna see tests for this gem, go take a look at the repository
|
7
|
+
# [on Github](https://github.com/codegram/date_validator)
|
8
|
+
describe "Date Validation" do
|
9
|
+
it "finds the translations" do
|
10
|
+
TestRecord.validates :start_date, :date => {:before => :end_date }
|
11
|
+
d = TestRecord.new(:start_date => Time.now, :end_date => Time.now - 1)
|
12
|
+
|
13
|
+
refute d.valid?
|
14
|
+
refute_includes d.errors.map(&:to_s).join, 'translation missing'
|
15
|
+
end
|
16
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activevalidators
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 1.7.
|
9
|
+
- 1
|
10
|
+
version: 1.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Franck Verrot
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date: 2011-
|
23
|
+
date: 2011-10-02 00:00:00 Z
|
24
24
|
dependencies:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bundler
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- lib/activevalidators.rb
|
173
173
|
- test/test_helper.rb
|
174
174
|
- test/validations/credit_card_test.rb
|
175
|
+
- test/validations/date_test.rb
|
175
176
|
- test/validations/email_test.rb
|
176
177
|
- test/validations/ip_test.rb
|
177
178
|
- test/validations/password_test.rb
|
@@ -218,6 +219,7 @@ summary: Collection of ActiveModel/ActiveRecord validations
|
|
218
219
|
test_files:
|
219
220
|
- test/test_helper.rb
|
220
221
|
- test/validations/credit_card_test.rb
|
222
|
+
- test/validations/date_test.rb
|
221
223
|
- test/validations/email_test.rb
|
222
224
|
- test/validations/ip_test.rb
|
223
225
|
- test/validations/password_test.rb
|