Merge pull request #1807 from betagouv/fred-comments

Fix issues spotted by @fredZen in #1802
This commit is contained in:
gregoirenovel 2018-04-06 16:44:40 +02:00 committed by GitHub
commit 2f2e26470d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -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

View file

@ -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