added define_write_method with simple parse and cace for dates, times and datetimes when time zone conversion is off and default for Rails 2.0

This commit is contained in:
Adam Meehan
2008-07-23 12:42:03 +10:00
parent 7500781887
commit 5c03d3d645
2 changed files with 22 additions and 20 deletions

View File

@@ -8,7 +8,7 @@ describe ValidatesTimeliness::AttributeMethods do
@person = Person.new
end
it "should call parser on write for time attribute" do
it "should call parser on write for datetime attribute" do
@person.class.should_receive(:parse_date_time).once
@person.birth_date_and_time = "2000-06-01 02:03:04"
end
@@ -18,6 +18,11 @@ describe ValidatesTimeliness::AttributeMethods do
@person.birth_date = "2000-06-01"
end
it "should call parser on write for time attribute" do
@person.class.should_receive(:parse_date_time).once
@person.birth_time = "12:00"
end
it "should return raw string value for attribute_before_type_cast when written as string" do
time_string = "2000-06-01 02:03:04"
@person.birth_date_and_time = time_string