validates_timeliness 3.0.3 → 3.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +1 -1
- data/lib/validates_timeliness/attribute_methods.rb +1 -1
- data/lib/validates_timeliness/validator.rb +3 -2
- data/lib/validates_timeliness/version.rb +1 -1
- data/spec/validates_timeliness/validator_spec.rb +12 -4
- data/validates_timeliness.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 3.0.4 [2011-01-22]
|
2
|
+
* Fix :between option which was being ignored (ebeigarts)
|
3
|
+
* Use class_attribute to remove deprecated class_inheritable_accessor
|
4
|
+
* Namespace copied validator class to ActiveModel::Validations::Timeliness for :timeliness option
|
5
|
+
|
1
6
|
= 3.0.3 [2010-12-11]
|
2
7
|
* Fix validation of values which don't respond to to_date or to_time (renatoelias)
|
3
8
|
|
data/README.rdoc
CHANGED
@@ -27,12 +27,13 @@ module ValidatesTimeliness
|
|
27
27
|
def initialize(options)
|
28
28
|
@type = options.delete(:type) || :datetime
|
29
29
|
@allow_nil, @allow_blank = options.delete(:allow_nil), options.delete(:allow_blank)
|
30
|
-
@restrictions_to_check = RESTRICTIONS.keys & options.keys
|
31
30
|
|
32
31
|
if range = options.delete(:between)
|
33
32
|
raise ArgumentError, ":between must be a Range or an Array" unless range.is_a?(Range) || range.is_a?(Array)
|
34
33
|
options[:on_or_after], options[:on_or_before] = range.first, range.last
|
35
34
|
end
|
35
|
+
|
36
|
+
@restrictions_to_check = RESTRICTIONS.keys & options.keys
|
36
37
|
super
|
37
38
|
end
|
38
39
|
|
@@ -85,4 +86,4 @@ module ValidatesTimeliness
|
|
85
86
|
end
|
86
87
|
|
87
88
|
# Compatibility with ActiveModel validates method which matches option keys to their validator class
|
88
|
-
TimelinessValidator = ValidatesTimeliness::Validator
|
89
|
+
ActiveModel::Validations::TimelinessValidator = ValidatesTimeliness::Validator
|
@@ -12,10 +12,10 @@ describe ValidatesTimeliness::Validator do
|
|
12
12
|
ValidatesTimeliness::Validator.kind.should == :timeliness
|
13
13
|
end
|
14
14
|
|
15
|
-
describe "Model.validates :timeliness option" do
|
15
|
+
describe "Model.validates with :timeliness option" do
|
16
16
|
it 'should use plugin validator class' do
|
17
17
|
Person.validates :birth_date, :timeliness => {:is_at => Date.new(2010,1,1), :type => :date}
|
18
|
-
Person.validators.should have(1).kind_of(TimelinessValidator)
|
18
|
+
Person.validators.should have(1).kind_of(ActiveModel::Validations::TimelinessValidator)
|
19
19
|
invalid!(:birth_date, Date.new(2010,1,2))
|
20
20
|
valid!(:birth_date, Date.new(2010,1,1))
|
21
21
|
end
|
@@ -70,18 +70,26 @@ describe ValidatesTimeliness::Validator do
|
|
70
70
|
describe "array value" do
|
71
71
|
it 'should be split option into :on_or_after and :on_or_before values' do
|
72
72
|
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
|
73
|
-
Person.
|
73
|
+
Person.validates_date :birth_date, :between => [on_or_after, on_or_before]
|
74
74
|
Person.validators.first.options[:on_or_after].should == on_or_after
|
75
75
|
Person.validators.first.options[:on_or_before].should == on_or_before
|
76
|
+
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
|
77
|
+
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
|
78
|
+
valid!(:birth_date, on_or_after)
|
79
|
+
valid!(:birth_date, on_or_before)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
|
79
83
|
describe "range value" do
|
80
84
|
it 'should be split option into :on_or_after and :on_or_before values' do
|
81
85
|
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
|
82
|
-
Person.
|
86
|
+
Person.validates_date :birth_date, :between => on_or_after..on_or_before
|
83
87
|
Person.validators.first.options[:on_or_after].should == on_or_after
|
84
88
|
Person.validators.first.options[:on_or_before].should == on_or_before
|
89
|
+
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
|
90
|
+
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
|
91
|
+
valid!(:birth_date, on_or_after)
|
92
|
+
valid!(:birth_date, on_or_before)
|
85
93
|
end
|
86
94
|
end
|
87
95
|
end
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{validates_timeliness}
|
5
|
-
s.version = "3.0.
|
5
|
+
s.version = "3.0.4"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Adam Meehan"]
|
9
|
-
s.date = %q{
|
9
|
+
s.date = %q{2011-01-22}
|
10
10
|
s.description = %q{Date and time validation plugin for Rails which allows custom formats}
|
11
11
|
s.email = %q{adam.meehan@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validates_timeliness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 3.0.
|
9
|
+
- 4
|
10
|
+
version: 3.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Adam Meehan
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-01-22 00:00:00 +11:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|