mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
reluctantly overriding whole execute_callstack_for_multiparameter_attributes method
this fixes issue for Date column types. Damn method is just too unwieldly and should be refactored in Rails.
This commit is contained in:
@@ -3,19 +3,31 @@ require 'spec_helper'
|
||||
describe ValidatesTimeliness::Extensions::MultiparameterHandler 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'
|
||||
context "time column" do
|
||||
it 'should return string value for invalid date portion' do
|
||||
multiparameter_attribute(:birth_datetime, [2000, 2, 31, 12, 0, 0])
|
||||
employee.birth_datetime_before_type_cast.should == '2000-02-31 12:00:00'
|
||||
end
|
||||
|
||||
it 'should return Time value for valid datetimes' do
|
||||
multiparameter_attribute(:birth_datetime, [2000, 2, 28, 12, 0, 0])
|
||||
employee.birth_datetime_before_type_cast.should be_kind_of(Time)
|
||||
end
|
||||
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
|
||||
|
||||
it 'should return Time value for valid datetimes' do
|
||||
instantiate_time_object('birth_datetime', [2000, 2, 28, 12, 0, 0]).should be_kind_of(Time)
|
||||
context "date column" do
|
||||
it 'should return string value for invalid date' do
|
||||
multiparameter_attribute(:birth_date, [2000, 2, 31])
|
||||
employee.birth_date_before_type_cast.should == '2000-02-31'
|
||||
end
|
||||
|
||||
it 'should return Date value for valid date' do
|
||||
multiparameter_attribute(:birth_date, [2000, 2, 28])
|
||||
employee.birth_date_before_type_cast.should be_kind_of(Date)
|
||||
end
|
||||
end
|
||||
|
||||
def instantiate_time_object(name, values)
|
||||
employee.send(:instantiate_time_object, name, values)
|
||||
def multiparameter_attribute(name, values)
|
||||
employee.send(:execute_callstack_for_multiparameter_attributes, name.to_s => values)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user