default to datetime type using validates method

This commit is contained in:
Adam Meehan 2010-08-02 18:13:04 +10:00
parent 896fd83be5
commit e91d5a3404
2 changed files with 6 additions and 1 deletions

View File

@ -18,7 +18,7 @@ module ValidatesTimeliness
def initialize(options)
@allow_nil, @allow_blank = options.delete(:allow_nil), options.delete(:allow_blank)
@type = options.delete(:type)
@type = options.delete(:type) || :datetime
@check_restrictions = RESTRICTIONS.keys & options.keys
if range = options.delete(:between)

View File

@ -19,6 +19,11 @@ describe ValidatesTimeliness::Validator do
invalid!(:birth_date, Date.new(2010,1,2))
valid!(:birth_date, Date.new(2010,1,1))
end
it 'should use default to :datetime type' do
Person.validates :birth_datetime, :timeliness => {:is_at => Time.mktime(2010,1,1)}
Person.validators.first.instance_variable_get(:@type).should == :datetime
end
end
describe ":allow_nil option" do