mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
Move timeliness defined methods to a module so they can be overwritten.
This commit is contained in:
@@ -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|
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user