mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
default to datetime type using validates method
This commit is contained in:
parent
896fd83be5
commit
e91d5a3404
@ -18,7 +18,7 @@ module ValidatesTimeliness
|
|||||||
|
|
||||||
def initialize(options)
|
def initialize(options)
|
||||||
@allow_nil, @allow_blank = options.delete(:allow_nil), options.delete(:allow_blank)
|
@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
|
@check_restrictions = RESTRICTIONS.keys & options.keys
|
||||||
|
|
||||||
if range = options.delete(:between)
|
if range = options.delete(:between)
|
||||||
|
|||||||
@ -19,6 +19,11 @@ describe ValidatesTimeliness::Validator do
|
|||||||
invalid!(:birth_date, Date.new(2010,1,2))
|
invalid!(:birth_date, Date.new(2010,1,2))
|
||||||
valid!(:birth_date, Date.new(2010,1,1))
|
valid!(:birth_date, Date.new(2010,1,1))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe ":allow_nil option" do
|
describe ":allow_nil option" do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user