Skip to content
Extraits de code Groupes Projets
Valider 427cf183 rédigé par maxwell's avatar maxwell
Parcourir les fichiers

fix birthday spec

parent 84c041ba
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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
......
......@@ -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
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter