refactor(champ): more concistent champ_for_update usage
This commit is contained in:
parent
988025ba69
commit
54926db89b
3 changed files with 8 additions and 6 deletions
|
@ -9,7 +9,11 @@ class Champs::ChampController < ApplicationController
|
|||
def find_champ
|
||||
dossier = policy_scope(Dossier).includes(:champs, revision: [:types_de_champ]).find(params[:dossier_id])
|
||||
type_de_champ = dossier.find_type_de_champ_by_stable_id(params[:stable_id])
|
||||
dossier.champ_for_update(type_de_champ, params_row_id, updated_by: current_user.email)
|
||||
if type_de_champ.repetition?
|
||||
dossier.project_champ(type_de_champ, nil)
|
||||
else
|
||||
dossier.champ_for_update(type_de_champ, params_row_id, updated_by: current_user.email)
|
||||
end
|
||||
end
|
||||
|
||||
def params_row_id
|
||||
|
|
|
@ -57,7 +57,7 @@ module DossierChampsConcern
|
|||
.types_de_champ
|
||||
.filter { _1.stable_id.in?(stable_ids) }
|
||||
.filter { !revision.child?(_1) }
|
||||
.map { champ_for_update(_1, nil, updated_by: nil) }
|
||||
.map { _1.repetition? ? project_champ(_1, nil) : champ_for_update(_1, nil, updated_by: nil) }
|
||||
end
|
||||
|
||||
def champ_for_update(type_de_champ, row_id, updated_by:)
|
||||
|
|
|
@ -38,10 +38,8 @@ describe DossierSearchableConcern do
|
|||
end
|
||||
|
||||
it "update columns en construction" do
|
||||
dossier.update(
|
||||
champs_public_attributes: [{ id: champ_public.id, value: 'nouvelle valeur publique' }],
|
||||
champs_private_attributes: [{ id: champ_private.id, value: 'nouvelle valeur privee' }]
|
||||
)
|
||||
dossier.update_champs_attributes({ champ_public.public_id => { value: 'nouvelle valeur publique' } }, :public, updated_by: 'test')
|
||||
dossier.update_champs_attributes({ champ_private.public_id => { value: 'nouvelle valeur privee' } }, :private, updated_by: 'test')
|
||||
|
||||
assert_enqueued_jobs(1, only: DossierIndexSearchTermsJob) do
|
||||
dossier.passer_en_construction
|
||||
|
|
Loading…
Reference in a new issue