Compare commits

...

6 Commits
3.0.3 ... 3.0.4

Author SHA1 Message Date
Adam Meehan
bbb752e4e3 version 3.0.4 2011-01-22 11:16:10 +11:00
Adam Meehan
9d4ac8d513 update test gems 2011-01-22 11:15:15 +11:00
Adam Meehan
54347ee682 doc tweak 2011-01-22 10:49:59 +11:00
Adam Meehan
54ba4a038c use namespaced validator class name for the :timeliness option 2011-01-22 10:48:40 +11:00
Adam Meehan
7b5b11ad63 use class_attribute again, now that I know how to use it safely 2011-01-22 10:47:22 +11:00
Edgars Beigarts
d14ae09820 Fixed :between option. 2011-01-21 11:02:59 +02:00
9 changed files with 97 additions and 84 deletions

View File

@@ -1,3 +1,8 @@
= 3.0.4 [2011-01-22]
* Fix :between option which was being ignored (ebeigarts)
* Use class_attribute to remove deprecated class_inheritable_accessor
* Namespace copied validator class to ActiveModel::Validations::Timeliness for :timeliness option
= 3.0.3 [2010-12-11]
* Fix validation of values which don't respond to to_date or to_time (renatoelias)

View File

@@ -3,15 +3,14 @@ source 'http://rubygems.org'
gemspec
gem 'ZenTest'
gem 'rails', '3.0.0'
gem 'rspec', '>= 2.0.0.beta.17'
gem 'rspec-rails', '>= 2.0.0.beta.17'
gem 'rails', '3.0.3'
gem 'rspec', '~> 2.4'
gem 'rspec-rails', '~> 2.4'
gem 'timecop'
gem 'rspec_tag_matchers'
group :mongoid do
gem 'mongoid', '2.0.0.beta.19'
gem 'bson_ext', '1.0.4'
gem 'mongoid', '2.0.0.rc.6'
end
group :active_record do

View File

@@ -1,105 +1,106 @@
PATH
remote: .
specs:
validates_timeliness (3.0.2)
validates_timeliness (3.0.4)
timeliness (~> 0.3.2)
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.4.0)
ZenTest (4.4.2)
abstract (1.0.0)
actionmailer (3.0.0)
actionpack (= 3.0.0)
mail (~> 2.2.5)
actionpack (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
actionmailer (3.0.3)
actionpack (= 3.0.3)
mail (~> 2.2.9)
actionpack (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4.1)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.12)
rack-test (~> 0.5.4)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.6)
tzinfo (~> 0.3.23)
activemodel (3.0.0)
activesupport (= 3.0.0)
activemodel (3.0.3)
activesupport (= 3.0.3)
builder (~> 2.1.2)
i18n (~> 0.4.1)
activerecord (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
arel (~> 1.0.0)
i18n (~> 0.4)
activerecord (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.0)
activemodel (= 3.0.0)
activesupport (= 3.0.0)
activesupport (3.0.0)
arel (1.0.1)
activesupport (~> 3.0.0)
bson (1.1.1)
bson_ext (1.0.4)
activeresource (3.0.3)
activemodel (= 3.0.3)
activesupport (= 3.0.3)
activesupport (3.0.3)
arel (2.0.7)
bson (1.2.0)
builder (2.1.2)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
i18n (0.4.2)
mail (2.2.10)
i18n (0.5.0)
mail (2.2.14)
activesupport (>= 2.3.6)
i18n (~> 0.4.1)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
mongo (1.0.9)
bson (>= 1.0.5)
mongoid (2.0.0.beta.19)
mongo (1.2.0)
bson (>= 1.2.0)
mongoid (2.0.0.rc.6)
activemodel (~> 3.0)
mongo (= 1.0.9)
mongo (~> 1.2)
tzinfo (~> 0.3.22)
will_paginate (~> 3.0.pre)
nokogiri (1.4.3.1)
nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.6)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
actionpack (= 3.0.0)
activerecord (= 3.0.0)
activeresource (= 3.0.0)
activesupport (= 3.0.0)
bundler (~> 1.0.0)
railties (= 3.0.0)
railties (3.0.0)
actionpack (= 3.0.0)
activesupport (= 3.0.0)
rake (>= 0.8.4)
thor (~> 0.14.0)
rails (3.0.3)
actionmailer (= 3.0.3)
actionpack (= 3.0.3)
activerecord (= 3.0.3)
activeresource (= 3.0.3)
activesupport (= 3.0.3)
bundler (~> 1.0)
railties (= 3.0.3)
railties (3.0.3)
actionpack (= 3.0.3)
activesupport (= 3.0.3)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
rspec (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-mocks (= 2.0.0.beta.22)
rspec-core (2.0.0.beta.22)
rspec-expectations (2.0.0.beta.22)
diff-lcs (>= 1.1.2)
rspec-mocks (2.0.0.beta.22)
rspec-core (= 2.0.0.beta.22)
rspec-expectations (= 2.0.0.beta.22)
rspec-rails (2.0.0.beta.22)
rspec (= 2.0.0.beta.22)
rspec (2.4.0)
rspec-core (~> 2.4.0)
rspec-expectations (~> 2.4.0)
rspec-mocks (~> 2.4.0)
rspec-core (2.4.0)
rspec-expectations (2.4.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.4.0)
rspec-rails (2.4.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.4.0)
rspec_tag_matchers (1.0.0)
nokogiri (>= 1.4.0)
rspec-rails (>= 1.2.6)
sqlite3-ruby (1.3.1)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
thor (0.14.6)
timecop (0.3.5)
timeliness (0.3.2)
timeliness (0.3.3)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
tzinfo (0.3.24)
will_paginate (3.0.pre2)
PLATFORMS
@@ -107,11 +108,10 @@ PLATFORMS
DEPENDENCIES
ZenTest
bson_ext (= 1.0.4)
mongoid (= 2.0.0.beta.19)
rails (= 3.0.0)
rspec (>= 2.0.0.beta.17)
rspec-rails (>= 2.0.0.beta.17)
mongoid (= 2.0.0.rc.6)
rails (= 3.0.3)
rspec (~> 2.4)
rspec-rails (~> 2.4)
rspec_tag_matchers
sqlite3-ruby
timecop

View File

@@ -24,7 +24,7 @@ If you a looking for the old version for Rails 2.x go here[http://github.com/adz
* Supports I18n for the error messages
* Supports MRI 1.8.x and 1.9.x and Rubinius.
* Supports Ruby 1.8.x, 1.9.x and Rubinius.
== Installation

View File

@@ -3,7 +3,7 @@ module ValidatesTimeliness
extend ActiveSupport::Concern
included do
class_inheritable_accessor :timeliness_validated_attributes
class_attribute :timeliness_validated_attributes
self.timeliness_validated_attributes = []
end

View File

@@ -27,12 +27,13 @@ module ValidatesTimeliness
def initialize(options)
@type = options.delete(:type) || :datetime
@allow_nil, @allow_blank = options.delete(:allow_nil), options.delete(:allow_blank)
@restrictions_to_check = RESTRICTIONS.keys & options.keys
if range = options.delete(:between)
raise ArgumentError, ":between must be a Range or an Array" unless range.is_a?(Range) || range.is_a?(Array)
options[:on_or_after], options[:on_or_before] = range.first, range.last
end
@restrictions_to_check = RESTRICTIONS.keys & options.keys
super
end
@@ -85,4 +86,4 @@ module ValidatesTimeliness
end
# Compatibility with ActiveModel validates method which matches option keys to their validator class
TimelinessValidator = ValidatesTimeliness::Validator
ActiveModel::Validations::TimelinessValidator = ValidatesTimeliness::Validator

View File

@@ -1,3 +1,3 @@
module ValidatesTimeliness
VERSION = '3.0.3'
VERSION = '3.0.4'
end

View File

@@ -12,10 +12,10 @@ describe ValidatesTimeliness::Validator do
ValidatesTimeliness::Validator.kind.should == :timeliness
end
describe "Model.validates :timeliness option" do
describe "Model.validates with :timeliness option" do
it 'should use plugin validator class' do
Person.validates :birth_date, :timeliness => {:is_at => Date.new(2010,1,1), :type => :date}
Person.validators.should have(1).kind_of(TimelinessValidator)
Person.validators.should have(1).kind_of(ActiveModel::Validations::TimelinessValidator)
invalid!(:birth_date, Date.new(2010,1,2))
valid!(:birth_date, Date.new(2010,1,1))
end
@@ -70,18 +70,26 @@ describe ValidatesTimeliness::Validator do
describe "array value" do
it 'should be split option into :on_or_after and :on_or_before values' do
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
Person.validates_time :birth_date, :between => [on_or_after, on_or_before]
Person.validates_date :birth_date, :between => [on_or_after, on_or_before]
Person.validators.first.options[:on_or_after].should == on_or_after
Person.validators.first.options[:on_or_before].should == on_or_before
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
valid!(:birth_date, on_or_after)
valid!(:birth_date, on_or_before)
end
end
describe "range value" do
it 'should be split option into :on_or_after and :on_or_before values' do
on_or_after, on_or_before = Date.new(2010,1,1), Date.new(2010,1,2)
Person.validates_time :birth_date, :between => on_or_after..on_or_before
Person.validates_date :birth_date, :between => on_or_after..on_or_before
Person.validators.first.options[:on_or_after].should == on_or_after
Person.validators.first.options[:on_or_before].should == on_or_before
invalid!(:birth_date, on_or_after - 1, "must be on or after 2010-01-01")
invalid!(:birth_date, on_or_before + 1, "must be on or before 2010-01-02")
valid!(:birth_date, on_or_after)
valid!(:birth_date, on_or_before)
end
end
end

View File

@@ -2,11 +2,11 @@
Gem::Specification.new do |s|
s.name = %q{validates_timeliness}
s.version = "3.0.3"
s.version = "3.0.4"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Adam Meehan"]
s.date = %q{2010-12-11}
s.date = %q{2011-01-22}
s.description = %q{Date and time validation plugin for Rails which allows custom formats}
s.email = %q{adam.meehan@gmail.com}
s.extra_rdoc_files = ["README.rdoc", "CHANGELOG.rdoc", "LICENSE"]