From fb463ca7a037fc3df085754dbf0ad22f1e229b1e Mon Sep 17 00:00:00 2001 From: Adam Meehan Date: Wed, 21 May 2008 17:03:19 +1000 Subject: [PATCH] fixed time object passed to strict_time_type_cast error --- lib/validates_timeliness/base.rb | 2 +- spec/base_spec.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/validates_timeliness/base.rb b/lib/validates_timeliness/base.rb index 30f4636..22d8634 100644 --- a/lib/validates_timeliness/base.rb +++ b/lib/validates_timeliness/base.rb @@ -33,7 +33,7 @@ module ValidatesTimeliness def strict_time_type_cast(time) if time.acts_like?(:time) - time.respond_to?(:in_time_zone) ? time.time.in_time_zone : time + time.respond_to?(:in_time_zone) ? time.in_time_zone : time else klass = ActiveRecord::ConnectionAdapters::Column # check for invalid date diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 3d3d99f..83540fd 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -47,6 +47,10 @@ describe ValidatesTimeliness::Base do it "should return nil for time string with invalid time part" do strict_time_type_cast("2000-02-01 25:13:14").should be_nil end + + it "should return time object for time object" do + strict_time_type_cast(Time.now).should be_kind_of(Time) + end end describe "read_attribute" do