Move timeliness defined methods to a module so they can be overwritten.

This commit is contained in:
José Valim
2010-11-01 14:56:03 -02:00
parent 0e3f56e26d
commit 889b5a9b07
3 changed files with 19 additions and 2 deletions

View File

@@ -75,6 +75,13 @@ class Employee < ActiveRecord::Base
validates_time :birth_time
validates_datetime :birth_datetime
define_attribute_methods
attr_accessor :redefined_birth_date_called
def birth_date=(value)
self.redefined_birth_date_called = true
super
end
end
Rspec.configure do |c|

View File

@@ -34,6 +34,12 @@ describe ValidatesTimeliness::AttributeMethods do
r._timeliness_raw_value_for(:birth_datetime).should == date_string
end
it 'should not overwrite user defined methods' do
e = Employee.new
e.birth_date = '2010-01-01'
e.redefined_birth_date_called.should be_true
end
context "with plugin parser" do
class PersonWithParser
include TestModel