fix birthday spec

This commit is contained in:
maxwell 2010-12-17 19:41:20 -08:00
parent 84c041ba6a
commit 427cf18324
2 changed files with 5 additions and 5 deletions

View file

@ -88,12 +88,12 @@ class Profile
end
def date= params
params['year'] = '1000' if params['year'].blank?
if ['month', 'day'].all? { |key| params[key].present? }
if ['month', 'day'].all? { |key| params[key].present? }
params['year'] = '1000' if params['year'].blank?
date = Date.new(params['year'].to_i, params['month'].to_i, params['day'].to_i)
self.birthday = date
elsif ['month', 'day'].all? { |key| params[key].blank? }
self.birthday = nil
elsif [ 'year', 'month', 'day'].all? { |key| params[key].blank? }
self.birthday = nil
end
end

View file

@ -91,7 +91,7 @@ describe Profile do
profile.birthday.should == nil
end
it 'does not change with one or more blank values' do
it 'does not change with blank month and day values' do
profile.birthday = Date.new(2000, 1, 1)
profile.date = { 'year' => '2001', 'month' => '', 'day' => ''}
profile.birthday.year.should == 2000