mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
parse_date_time method returns for date column to return Date object when assigned string as per normal Rails
parse_date_time method returns same object when assigned Date or Time object
This commit is contained in:
@@ -34,11 +34,26 @@ describe ValidatesTimeliness::AttributeMethods do
|
||||
@person.birth_date_and_time_before_type_cast.should be_kind_of(Time)
|
||||
end
|
||||
|
||||
it "should return Time object using attribute read method when written with string" do
|
||||
it "should return Time object for datetime attribute read method when assigned Time object" do
|
||||
@person.birth_date_and_time = Time.now
|
||||
@person.birth_date_and_time.should be_kind_of(Time)
|
||||
end
|
||||
|
||||
it "should return Time object for datetime attribute read method when assigned string" do
|
||||
@person.birth_date_and_time = "2000-01-01 02:03:04"
|
||||
@person.birth_date_and_time.should be_kind_of(Time)
|
||||
end
|
||||
|
||||
it "should return Date object for date attribute read method when assigned Date object" do
|
||||
@person.birth_date = Date.today
|
||||
@person.birth_date.should be_kind_of(Date)
|
||||
end
|
||||
|
||||
it "should return Date object for date attribute read method when assigned string" do
|
||||
@person.birth_date = '2000-01-01'
|
||||
@person.birth_date.should be_kind_of(Date)
|
||||
end
|
||||
|
||||
it "should return nil when time is invalid" do
|
||||
@person.birth_date_and_time = "2000-01-32 02:03:04"
|
||||
@person.birth_date_and_time.should be_nil
|
||||
|
||||
Reference in New Issue
Block a user