mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 15:22:58 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
01d1dc7c5e | ||
|
|
b09f937688 | ||
|
|
509336e080 | ||
|
|
e345b5dc7d | ||
|
|
57eef70b7c |
@@ -1,3 +1,6 @@
|
||||
= 3.0.3 [2010-12-11]
|
||||
* Fix validation of values which don't respond to to_date or to_time (renatoelias)
|
||||
|
||||
= 3.0.2 [2010-12-04]
|
||||
* Fix AR multiparameter extension for Date columns
|
||||
* Update to Timeliness 0.3.2 for zone abbreviation and offset support
|
||||
|
||||
1
Gemfile
1
Gemfile
@@ -8,7 +8,6 @@ gem 'rspec', '>= 2.0.0.beta.17'
|
||||
gem 'rspec-rails', '>= 2.0.0.beta.17'
|
||||
gem 'timecop'
|
||||
gem 'rspec_tag_matchers'
|
||||
gem 'ruby-debug'
|
||||
|
||||
group :mongoid do
|
||||
gem 'mongoid', '2.0.0.beta.19'
|
||||
|
||||
14
Gemfile.lock
14
Gemfile.lock
@@ -40,13 +40,11 @@ GEM
|
||||
bson (1.1.1)
|
||||
bson_ext (1.0.4)
|
||||
builder (2.1.2)
|
||||
columnize (0.3.1)
|
||||
diff-lcs (1.1.2)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
i18n (0.4.2)
|
||||
linecache (0.43)
|
||||
mail (2.2.9)
|
||||
mail (2.2.10)
|
||||
activesupport (>= 2.3.6)
|
||||
i18n (~> 0.4.1)
|
||||
mime-types (~> 1.16)
|
||||
@@ -95,16 +93,11 @@ GEM
|
||||
rspec_tag_matchers (1.0.0)
|
||||
nokogiri (>= 1.4.0)
|
||||
rspec-rails (>= 1.2.6)
|
||||
ruby-debug (0.10.3)
|
||||
columnize (>= 0.1)
|
||||
ruby-debug-base (~> 0.10.3.0)
|
||||
ruby-debug-base (0.10.3)
|
||||
linecache (>= 0.3)
|
||||
sqlite3-ruby (1.3.1)
|
||||
thor (0.14.3)
|
||||
thor (0.14.6)
|
||||
timecop (0.3.5)
|
||||
timeliness (0.3.2)
|
||||
treetop (1.4.8)
|
||||
treetop (1.4.9)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.23)
|
||||
will_paginate (3.0.pre2)
|
||||
@@ -120,7 +113,6 @@ DEPENDENCIES
|
||||
rspec (>= 2.0.0.beta.17)
|
||||
rspec-rails (>= 2.0.0.beta.17)
|
||||
rspec_tag_matchers
|
||||
ruby-debug
|
||||
sqlite3-ruby
|
||||
timecop
|
||||
timeliness (~> 0.3.2)
|
||||
|
||||
@@ -24,6 +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.
|
||||
|
||||
== Installation
|
||||
|
||||
@@ -34,7 +35,7 @@ As plugin (from master)
|
||||
As gem
|
||||
|
||||
# in Gemfile
|
||||
gem 'validates_timeliness', '~> 3.0.0'
|
||||
gem 'validates_timeliness', '~> 3.0.2'
|
||||
|
||||
# Run bundler
|
||||
$ bundle install
|
||||
|
||||
@@ -2,7 +2,7 @@ module ValidatesTimeliness
|
||||
module Conversion
|
||||
|
||||
def type_cast_value(value, type)
|
||||
return nil if value.nil?
|
||||
return nil if value.nil? || !value.respond_to?(:to_time)
|
||||
|
||||
value = value.in_time_zone if value.acts_like?(:time) && @timezone_aware
|
||||
value = case type
|
||||
|
||||
@@ -72,9 +72,8 @@ module ValidatesTimeliness
|
||||
end
|
||||
|
||||
def attribute_raw_value(record, attr_name)
|
||||
if record.respond_to?(:_timeliness_raw_value_for)
|
||||
record.respond_to?(:_timeliness_raw_value_for) &&
|
||||
record._timeliness_raw_value_for(attr_name)
|
||||
end
|
||||
end
|
||||
|
||||
def timezone_aware?(record, attr_name)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
module ValidatesTimeliness
|
||||
VERSION = '3.0.2'
|
||||
VERSION = '3.0.3'
|
||||
end
|
||||
|
||||
@@ -22,6 +22,10 @@ describe ValidatesTimeliness::Conversion do
|
||||
it "should return date part of datetime value" do
|
||||
type_cast_value(DateTime.new(2010, 1, 1, 0, 0, 0), :date).should == Date.new(2010, 1, 1)
|
||||
end
|
||||
|
||||
it 'should return nil for invalid value types' do
|
||||
type_cast_value(12, :date).should == nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "for time type" do
|
||||
@@ -40,6 +44,10 @@ describe ValidatesTimeliness::Conversion do
|
||||
it "should return dummy date with time part for datetime value" do
|
||||
type_cast_value(DateTime.civil_from_format(:utc, 2010, 1, 1, 12, 34, 56), :time).should == Time.utc(2000, 1, 1, 12, 34, 56)
|
||||
end
|
||||
|
||||
it 'should return nil for invalid value types' do
|
||||
type_cast_value(12, :time).should == nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "for datetime type" do
|
||||
@@ -63,6 +71,10 @@ describe ValidatesTimeliness::Conversion do
|
||||
result.should == Time.zone.local(2010, 1, 1, 23, 34, 56)
|
||||
result.zone.should == 'EST'
|
||||
end
|
||||
|
||||
it 'should return nil for invalid value types' do
|
||||
type_cast_value(12, :datetime).should == nil
|
||||
end
|
||||
end
|
||||
|
||||
describe "ignore_usec option" do
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
Gem::Specification.new do |s|
|
||||
s.name = %q{validates_timeliness}
|
||||
s.version = "3.0.2"
|
||||
s.version = "3.0.3"
|
||||
|
||||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
||||
s.authors = ["Adam Meehan"]
|
||||
s.date = %q{2010-12-04}
|
||||
s.date = %q{2010-12-11}
|
||||
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"]
|
||||
|
||||
Reference in New Issue
Block a user