Fix issues spotted by @fredZen in #1802
This commit is contained in:
parent
f2f7fae6c9
commit
c60c58ff8b
2 changed files with 5 additions and 2 deletions
|
@ -50,6 +50,9 @@ class AttestationTemplate < ApplicationRecord
|
|||
def used_tags
|
||||
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]
|
||||
.map { |str| str.scan(delimiters_regex) }
|
||||
.flatten
|
||||
|
|
|
@ -286,7 +286,7 @@ class Dossier < ApplicationRecord
|
|||
def unspecified_attestation_champs
|
||||
attestation_template = procedure.attestation_template
|
||||
|
||||
if attestation_template.present? && attestation_template.activated?
|
||||
if attestation_template&.activated?
|
||||
attestation_template.unspecified_champs_for_dossier(self)
|
||||
else
|
||||
[]
|
||||
|
@ -294,7 +294,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def build_attestation
|
||||
if procedure.attestation_template.present? && procedure.attestation_template.activated?
|
||||
if procedure.attestation_template&.activated?
|
||||
procedure.attestation_template.attestation_for(self)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue