mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
fixed time object passed to strict_time_type_cast error
This commit is contained in:
parent
a9b033e539
commit
fb463ca7a0
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user