mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-25 07:16:41 +00:00
fixed bug with attribute cache not clearing on write for date and time columns
This commit is contained in:
parent
cd9f4d2d54
commit
b9f11a1f7b
@ -1,3 +1,6 @@
|
|||||||
|
[2008-08-22]
|
||||||
|
- fixed bug with attribute cache not clearing on write for date and time columns
|
||||||
|
|
||||||
[2008-08-07]
|
[2008-08-07]
|
||||||
- modified matcher option value parsing to allow same value types as validation method
|
- modified matcher option value parsing to allow same value types as validation method
|
||||||
- fixed matcher message
|
- fixed matcher message
|
||||||
|
|||||||
@ -146,7 +146,7 @@ module ValidatesTimeliness
|
|||||||
def define_write_method_for_dates_and_times(attr_name, type)
|
def define_write_method_for_dates_and_times(attr_name, type)
|
||||||
method_body = <<-EOV
|
method_body = <<-EOV
|
||||||
def #{attr_name}=(value)
|
def #{attr_name}=(value)
|
||||||
@attributes_cache['#{attr_name}'] ||= self.class.parse_date_time(value, :#{type})
|
@attributes_cache['#{attr_name}'] = self.class.parse_date_time(value, :#{type})
|
||||||
@attributes['#{attr_name}'] = value
|
@attributes['#{attr_name}'] = value
|
||||||
end
|
end
|
||||||
EOV
|
EOV
|
||||||
|
|||||||
@ -109,4 +109,14 @@ describe ValidatesTimeliness::AttributeMethods do
|
|||||||
@person.birth_date_and_time.should == time
|
@person.birth_date_and_time.should == time
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should return correct value after new value assigned" do
|
||||||
|
today = Date.today
|
||||||
|
tomorrow = Date.today + 1.day
|
||||||
|
@person = Person.new
|
||||||
|
@person.birth_date = today
|
||||||
|
@person.birth_date.should == today
|
||||||
|
@person.birth_date = tomorrow
|
||||||
|
@person.birth_date.should == tomorrow
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user