multiparameter extension for AR

This commit is contained in:
Adam Meehan
2010-08-03 22:59:29 +10:00
parent 81030a6ed8
commit 0f41671b32
4 changed files with 60 additions and 1 deletions

View File

@@ -17,6 +17,7 @@ require 'validates_timeliness'
ValidatesTimeliness.setup do |c|
c.extend_classes = [ ActiveModel::Validations, ActiveRecord::Base ]
c.enable_date_time_select_extension!
c.enable_multiparameter_parser!
end
Time.zone = 'Australia/Melbourne'

View File

@@ -0,0 +1,22 @@
require 'spec_helper'
describe ValidatesTimeliness::Extensions::MultiparameterParser do
let(:employee) { Employee.new }
it 'should return string value for invalid dates' do
instantiate_time_object('birth_date', [2000, 2, 31]).should == '2000-02-31'
end
it 'should return string value for invalid datetimes' do
instantiate_time_object('birth_datetime', [2000, 2, 31, 12, 0, 0]).should == '2000-02-31 12:00:00'
end
# This is giving an error in AR for undefined @@default_timezone.
# it 'should return Time value for valid datetimes' do
# instantiate_time_object('birth_datetime', [2000, 2, 28, 12, 0, 0]).should be_find_of(Time)
# end
def instantiate_time_object(name, values)
employee.send(:instantiate_time_object, name, values)
end
end