mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
use inheritable hash for valdiated attributes
This commit is contained in:
parent
4f8b300261
commit
423d60f885
@ -5,7 +5,7 @@ module ValidatesTimeliness
|
||||
included do
|
||||
include ValidationMethods
|
||||
extend ValidationMethods
|
||||
class_inheritable_accessor :timeliness_validated_attributes
|
||||
class_inheritable_hash :timeliness_validated_attributes
|
||||
self.timeliness_validated_attributes = {}
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@ module ValidatesTimeliness
|
||||
validated[attr_name] = options[:type]
|
||||
validated
|
||||
}
|
||||
timeliness_validated_attributes.update(attributes)
|
||||
self.timeliness_validated_attributes = attributes
|
||||
validates_with Validator, options
|
||||
end
|
||||
|
||||
|
||||
@ -21,8 +21,16 @@ describe ValidatesTimeliness::HelperMethods do
|
||||
|
||||
describe ".timeliness_validated_attributes" do
|
||||
it 'should return attributes validated with plugin validator' do
|
||||
Person.timeliness_validated_attributes = {}
|
||||
Person.validates_date :birth_date
|
||||
Person.timeliness_validated_attributes.should == {"birth_date" => :date}
|
||||
Person.validates_time :birth_time
|
||||
Person.validates_datetime :birth_datetime
|
||||
|
||||
Person.timeliness_validated_attributes.should == {
|
||||
"birth_date" => :date,
|
||||
"birth_time" => :time,
|
||||
"birth_datetime" => :datetime
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user