Fix false positive blank champ warnings
This commit is contained in:
parent
ac0f50b488
commit
388fb39eb5
2 changed files with 4 additions and 8 deletions
|
@ -39,16 +39,12 @@ class AttestationTemplate < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def unspecified_champs_for_dossier(dossier)
|
def unspecified_champs_for_dossier(dossier)
|
||||||
all_champs_with_libelle_index = (dossier.champs + dossier.champs_private)
|
all_champs_with_libelle_index = (dossier.champs + dossier.champs_private).index_by { |champ| "tdc#{champ.stable_id}" }
|
||||||
.reduce({}) do |acc, champ|
|
|
||||||
acc[champ.libelle] = champ
|
|
||||||
acc
|
|
||||||
end
|
|
||||||
|
|
||||||
used_tags.filter_map do |used_tag|
|
used_tags.filter_map do |used_tag|
|
||||||
corresponding_champ = all_champs_with_libelle_index[used_tag]
|
corresponding_champ = all_champs_with_libelle_index[used_tag]
|
||||||
|
|
||||||
if corresponding_champ && corresponding_champ.value.blank?
|
if corresponding_champ && corresponding_champ.blank?
|
||||||
corresponding_champ
|
corresponding_champ
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -113,7 +109,7 @@ class AttestationTemplate < ApplicationRecord
|
||||||
# We can't use flat_map as scan will return 3 levels of array,
|
# We can't use flat_map as scan will return 3 levels of array,
|
||||||
# using flat_map would give us 2, whereas flatten will
|
# using flat_map would give us 2, whereas flatten will
|
||||||
# give us 1, which is what we want
|
# give us 1, which is what we want
|
||||||
[title, body]
|
[normalize_tags(title), normalize_tags(body)]
|
||||||
.map { |str| str.scan(delimiters_regex) }
|
.map { |str| str.scan(delimiters_regex) }
|
||||||
.flatten
|
.flatten
|
||||||
end
|
end
|
||||||
|
|
|
@ -564,7 +564,7 @@ describe Dossier do
|
||||||
|
|
||||||
describe "#unspecified_attestation_champs" do
|
describe "#unspecified_attestation_champs" do
|
||||||
let(:procedure) { create(:procedure, attestation_template: attestation_template, types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private) }
|
let(:procedure) { create(:procedure, attestation_template: attestation_template, types_de_champ: types_de_champ, types_de_champ_private: types_de_champ_private) }
|
||||||
let(:dossier) { create(:dossier, procedure: procedure, state: Dossier.states.fetch(:en_instruction)) }
|
let(:dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||||
let(:types_de_champ) { [] }
|
let(:types_de_champ) { [] }
|
||||||
let(:types_de_champ_private) { [] }
|
let(:types_de_champ_private) { [] }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue