diff --git a/app/tasks/maintenance/update_draft_revision_type_de_champs_task.rb b/app/tasks/maintenance/update_draft_revision_type_de_champs_task.rb index 5ce483abf06..af03e79ec2a 100644 --- a/app/tasks/maintenance/update_draft_revision_type_de_champs_task.rb +++ b/app/tasks/maintenance/update_draft_revision_type_de_champs_task.rb @@ -29,8 +29,7 @@ def process(row) fail "TypeDeChamp not found ! #{typed_id}" if stable_id.nil? tdc = revision.find_and_ensure_exclusive_use(stable_id) - - revision.move_type_de_champ(stable_id, compute_position(row, tdc.revision_type_de_champ)) + revision.move_type_de_champ(stable_id, Integer(row['new_position'])) tdc.update!( libelle: row["new_libelle"].strip, @@ -38,17 +37,5 @@ def process(row) mandatory: row["new_required"] == "true" ) end - - private - - def compute_position(row, rtdc) - position = Integer(row["new_position"]) - - if rtdc.child? - position - rtdc.parent.position - 1 - else - position - end - end end end diff --git a/spec/tasks/maintenance/update_draft_revision_type_de_champs_task_spec.rb b/spec/tasks/maintenance/update_draft_revision_type_de_champs_task_spec.rb index d5332d6f79d..57e01ef8d6d 100644 --- a/spec/tasks/maintenance/update_draft_revision_type_de_champs_task_spec.rb +++ b/spec/tasks/maintenance/update_draft_revision_type_de_champs_task_spec.rb @@ -21,9 +21,9 @@ module Maintenance demarche_id,id,new_libelle,new_description,new_required,new_position,delete_flag #{procedure.id},#{find_by_stable_id(12).to_typed_id},[NEW] Number,[NEW] Number desc,true,0, #{procedure.id},#{find_by_stable_id(13).to_typed_id},Bloc,[NEW] bloc desc,,1, - #{procedure.id},#{find_by_stable_id(132).to_typed_id},[NEW] RepNum,,true,2, - #{procedure.id},#{find_by_stable_id(131).to_typed_id},[NEW] RepText,,,3, - #{procedure.id},#{find_by_stable_id(11).to_typed_id},[supp] Text,,,4,true + #{procedure.id},#{find_by_stable_id(132).to_typed_id},[NEW] RepNum,,true,0, + #{procedure.id},#{find_by_stable_id(131).to_typed_id},[NEW] RepText,,,1, + #{procedure.id},#{find_by_stable_id(11).to_typed_id},[supp] Text,,,2,true CSV end