fixed time object passed to strict_time_type_cast error

This commit is contained in:
Adam Meehan 2008-05-21 17:03:19 +10:00
parent a9b033e539
commit fb463ca7a0
2 changed files with 5 additions and 1 deletions

View File

@ -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

View File

@ -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