fix(prefill): don't mark the dossier as prefilled when it's not (#8464)
A dossier should not be marked as prefilled when it's not, meaning when no prefill params are given.
This commit is contained in:
parent
51e97b2d89
commit
0046338e6a
2 changed files with 6 additions and 2 deletions
|
@ -4,8 +4,10 @@ module DossierPrefillableConcern
|
|||
extend ActiveSupport::Concern
|
||||
|
||||
def prefill!(champs_public_attributes)
|
||||
return unless champs_public_attributes.any?
|
||||
|
||||
attr = { prefilled: true }
|
||||
attr[:champs_public_attributes] = champs_public_attributes.map { |h| h.merge(prefilled: true) } if champs_public_attributes.any?
|
||||
attr[:champs_public_attributes] = champs_public_attributes.map { |h| h.merge(prefilled: true) }
|
||||
|
||||
assign_attributes(attr)
|
||||
save(validate: false)
|
||||
|
|
|
@ -17,7 +17,9 @@ RSpec.describe DossierPrefillableConcern do
|
|||
context 'when champs_public_attributes is empty' do
|
||||
let(:values) { [] }
|
||||
|
||||
it_behaves_like 'a dossier marked as prefilled'
|
||||
it "doesn't mark the dossier as prefilled" do
|
||||
expect { fill }.not_to change { dossier.reload.prefilled }.from(nil)
|
||||
end
|
||||
|
||||
it "doesn't change champs_public" do
|
||||
expect { fill }.not_to change { dossier.champs_public.to_a }
|
||||
|
|
Loading…
Reference in a new issue