mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
Fix type_cast_value for values which don't respond to to_time or to_date (renatoelias)
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user