[#1421] Use delegation rather than STI for TypeDeChamp

This commit is contained in:
Frederic Merizen 2018-09-11 18:57:51 +02:00
parent 4bb00e9875
commit 9beaa293cd
26 changed files with 82 additions and 65 deletions

View file

@ -15,7 +15,7 @@ namespace :'2018_05_14_add_annotation_privee_to_procedure' do
tdc.update_attribute(:order_place, tdc.order_place + 1)
end
new_tdc = TypesDeChamp::TextTypeDeChamp.create(
new_tdc = TypeDeChamp.create(
procedure_id: procedure_id,
private: true,
libelle: 'URL Espace de consultation',

View file

@ -34,7 +34,7 @@ namespace :'2018_07_31_nutriscore' do
end
discard_source_champ(
TypesDeChamp::TextTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'text',
order_place: siret_order_place,
libelle: 'Numéro SIRET'
@ -42,7 +42,7 @@ namespace :'2018_07_31_nutriscore' do
)
discard_source_champ(
TypesDeChamp::TextTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'text',
order_place: fonction_order_place,
libelle: 'Fonction'
@ -50,7 +50,7 @@ namespace :'2018_07_31_nutriscore' do
)
compute_destination_champ(
TypesDeChamp::TextTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'text',
order_place: fonction_order_place,
libelle: 'Fonction',
@ -66,7 +66,7 @@ namespace :'2018_07_31_nutriscore' do
end
compute_destination_champ(
TypesDeChamp::SiretTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'siret',
order_place: siret_order_place,
libelle: 'Numéro SIRET'
@ -80,7 +80,7 @@ namespace :'2018_07_31_nutriscore' do
end
compute_destination_champ(
TypesDeChamp::HeaderSectionTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'header_section',
order_place: 18,
libelle: 'PARTIE 3 : ZONE GEOGRAPHIQUE'
@ -90,7 +90,7 @@ namespace :'2018_07_31_nutriscore' do
end
compute_destination_champ(
TypesDeChamp::MultipleDropDownListTypeDeChamp.new(
TypeDeChamp.new(
type_champ: 'multiple_drop_down_list',
order_place: 19,
libelle: 'Pays de commercialisation',

View file

@ -57,7 +57,7 @@ module Tasks
def type_de_champ_to_expectation(tdc)
if tdc.present?
expectation = tdc.as_json(only: [:libelle, :type, :type_champ, :mandatory])
expectation = tdc.as_json(only: [:libelle, :type_champ, :mandatory])
expectation['drop_down'] = tdc.drop_down_list.presence&.options&.presence
expectation
else
@ -107,9 +107,6 @@ module Tasks
if actual_tdc.libelle != expected_tdc['libelle']
errors.append("incorrect libelle #{actual_tdc.libelle} (expected #{expected_tdc['libelle']})")
end
if actual_tdc.type != expected_tdc['type']
errors.append("incorrect type #{actual_tdc.type} (expected #{expected_tdc['type']})")
end
if actual_tdc.type_champ != expected_tdc['type_champ']
errors.append("incorrect type champ #{actual_tdc.type_champ} (expected #{expected_tdc['type_champ']})")
end