Apply suggestions from code review
Co-authored-by: Pierre de La Morinerie <kemenaran@gmail.com>
This commit is contained in:
parent
acb277e650
commit
179bb5a9fe
2 changed files with 7 additions and 7 deletions
|
@ -197,12 +197,12 @@ module TagsSubstitutionConcern
|
|||
end
|
||||
|
||||
def champ_public_tags(dossier: nil)
|
||||
types_de_champ = (dossier ? dossier : procedure.active_revision).types_de_champ
|
||||
types_de_champ = (dossier || procedure.active_revision).types_de_champ
|
||||
types_de_champ_tags(types_de_champ, Dossier::SOUMIS)
|
||||
end
|
||||
|
||||
def champ_private_tags(dossier: nil)
|
||||
types_de_champ = (dossier ? dossier : procedure.active_revision).types_de_champ_private
|
||||
types_de_champ = (dossier || procedure.active_revision).types_de_champ_private
|
||||
types_de_champ_tags(types_de_champ, Dossier::INSTRUCTION_COMMENCEE)
|
||||
end
|
||||
|
||||
|
@ -246,7 +246,7 @@ module TagsSubstitutionConcern
|
|||
end
|
||||
|
||||
def replace_tag(text, tag, data)
|
||||
libelle = Regexp.quote(tag[:id] ? tag[:id] : tag[:libelle])
|
||||
libelle = Regexp.quote(tag[:id].presence || tag[:libelle])
|
||||
|
||||
# allow any kind of space (non-breaking or other) in the tag’s libellé to match any kind of space in the template
|
||||
# (the '\\ |' is there because plain ASCII spaces were escaped by preceding Regexp.quote)
|
||||
|
|
|
@ -401,18 +401,18 @@ describe TagsSubstitutionConcern, type: :model do
|
|||
procedure.update!(draft_revision: procedure.create_new_revision, published_revision: procedure.draft_revision)
|
||||
end
|
||||
|
||||
context "replace by old label" do
|
||||
context "when using the champ's original label" do
|
||||
let(:template) { '--mon tag--' }
|
||||
|
||||
it "should replace tag" do
|
||||
it "replaces the tag" do
|
||||
is_expected.to eq('valeur')
|
||||
end
|
||||
end
|
||||
|
||||
context "replace by new label" do
|
||||
context "when using the champ's revised label" do
|
||||
let(:template) { '--ton tag--' }
|
||||
|
||||
it "should replace tag" do
|
||||
it "replaces the tag" do
|
||||
is_expected.to eq('valeur')
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue