Merge pull request #1807 from betagouv/fred-comments
Fix issues spotted by @fredZen in #1802
This commit is contained in:
commit
2f2e26470d
2 changed files with 5 additions and 2 deletions
|
@ -50,6 +50,9 @@ class AttestationTemplate < ApplicationRecord
|
||||||
def used_tags
|
def used_tags
|
||||||
delimiters_regex = /--(?<capture>((?!--).)*)--/
|
delimiters_regex = /--(?<capture>((?!--).)*)--/
|
||||||
|
|
||||||
|
# We can't use flat_map as scan will return 3 levels of array,
|
||||||
|
# using flat_map would give us 2, whereas flatten will
|
||||||
|
# give us 1, which is what we want
|
||||||
[title, body]
|
[title, body]
|
||||||
.map { |str| str.scan(delimiters_regex) }
|
.map { |str| str.scan(delimiters_regex) }
|
||||||
.flatten
|
.flatten
|
||||||
|
|
|
@ -286,7 +286,7 @@ class Dossier < ApplicationRecord
|
||||||
def unspecified_attestation_champs
|
def unspecified_attestation_champs
|
||||||
attestation_template = procedure.attestation_template
|
attestation_template = procedure.attestation_template
|
||||||
|
|
||||||
if attestation_template.present? && attestation_template.activated?
|
if attestation_template&.activated?
|
||||||
attestation_template.unspecified_champs_for_dossier(self)
|
attestation_template.unspecified_champs_for_dossier(self)
|
||||||
else
|
else
|
||||||
[]
|
[]
|
||||||
|
@ -294,7 +294,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def build_attestation
|
def build_attestation
|
||||||
if procedure.attestation_template.present? && procedure.attestation_template.activated?
|
if procedure.attestation_template&.activated?
|
||||||
procedure.attestation_template.attestation_for(self)
|
procedure.attestation_template.attestation_for(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue