Merge pull request #164 from Skud/blankplantingtime

Fixed bug where blank planting date didn't work
This commit is contained in:
Joseph Caudle committed 2013-04-01 23:51:05 -07:00
commit 5431cdcd71
2 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -42,6 +42,6 @@ class Planting < ActiveRecord::Base
end
def planted_at_string=(str)
self.planted_at = Time.parse(str)
self.planted_at = str == '' ? nil : Time.parse(str)
end
end
+5
View File
@@ -39,6 +39,11 @@ describe Planting do
@planting.planted_at.should == Time.local(2013, 03, 01)
end
it 'should accept blank dates' do
@planting.planted_at_string = ''
@planting.planted_at.should == nil
end
it "should output dates in ISO format" do
@planting.planted_at = Time.local(2013, 03, 01)
@planting.planted_at_string.should == "2013-03-01"