mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-23 06:16:44 +00:00
cache raw value in @attributes_cache which is AR convention but should work fine with non-AR ORM before type cast method for reading back cached raw value
23 lines
694 B
Ruby
23 lines
694 B
Ruby
require 'spec_helper'
|
|
|
|
describe ValidatesTimeliness::AttributeMethods do
|
|
before do
|
|
Employee.validates_datetime :birth_datetime
|
|
Employee.define_attribute_methods
|
|
end
|
|
|
|
it 'should define attribute write method for validated attributes' do
|
|
Employee.instance_methods(false).should include("birth_datetime=")
|
|
end
|
|
|
|
it 'should define attribute before_type_cast method for validated attributes' do
|
|
Employee.instance_methods(false).should include("birth_datetime_before_type_cast")
|
|
end
|
|
|
|
it 'should store original raw value on attribute write' do
|
|
r = Employee.new
|
|
r.birth_datetime = '2010-01-01'
|
|
r.birth_datetime_before_type_cast.should == '2010-01-01'
|
|
end
|
|
end
|