use namespaced validator class name for the :timeliness option

This commit is contained in:
Adam Meehan 2011-01-22 10:48:40 +11:00
parent 7b5b11ad63
commit 54ba4a038c
2 changed files with 3 additions and 3 deletions

View File

@ -86,4 +86,4 @@ module ValidatesTimeliness
end
# Compatibility with ActiveModel validates method which matches option keys to their validator class
TimelinessValidator = ValidatesTimeliness::Validator
ActiveModel::Validations::TimelinessValidator = ValidatesTimeliness::Validator

View File

@ -12,10 +12,10 @@ describe ValidatesTimeliness::Validator do
ValidatesTimeliness::Validator.kind.should == :timeliness
end
describe "Model.validates :timeliness option" do
describe "Model.validates with :timeliness option" do
it 'should use plugin validator class' do
Person.validates :birth_date, :timeliness => {:is_at => Date.new(2010,1,1), :type => :date}
Person.validators.should have(1).kind_of(TimelinessValidator)
Person.validators.should have(1).kind_of(ActiveModel::Validations::TimelinessValidator)
invalid!(:birth_date, Date.new(2010,1,2))
valid!(:birth_date, Date.new(2010,1,1))
end