ChampsService: add tests and refactor

This commit is contained in:
Simon Lehericey 2017-03-29 13:37:07 +02:00
parent c5159dde4b
commit 4df03fc28e
6 changed files with 119 additions and 23 deletions

View file

@ -28,6 +28,10 @@ class Champ < ActiveRecord::Base
same_date? num, '%M'
end
def mandatory_and_blank?
mandatory? && value.blank?
end
def same_date? num, compare
if type_champ == 'datetime' && !value.nil?
if value.to_datetime.strftime(compare) == num