Merge pull request #1177 from sgmap/fix_1110-remove_legacy_tags

Fix 1110 5. remove legacy tags
This commit is contained in:
Frederic Merizen 2018-01-09 10:49:30 +01:00 committed by GitHub
commit 45e5f77e52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 23 deletions

View file

@ -13,10 +13,8 @@ module MailTemplateConcern
replace_tags(body, dossier)
end
# TODO: remove legacy argument when removing legacy tags
def tags(reject_legacy: true, is_dossier_termine: self.class.const_get(:IS_DOSSIER_TERMINE))
super(is_dossier_termine: is_dossier_termine)
.reject { |tag| reject_legacy && tag[:is_legacy] }
def tags(is_dossier_termine: self.class.const_get(:IS_DOSSIER_TERMINE))
super
end
module ClassMethods
@ -29,15 +27,7 @@ module MailTemplateConcern
private
def dossier_tags
super +
[{ libelle: 'lien dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) } },
# TODO: remove legacy tags
{ libelle: 'numero_dossier', description: '', target: :id, is_legacy: true },
{ libelle: 'lien_dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) }, is_legacy: true },
{ libelle: 'libelle_procedure', description: '', lambda: -> (d) { d.procedure.libelle }, is_legacy: true },
{ libelle: 'date_de_decision', description: '',
lambda: -> (d) { d.processed_at.present? ? d.processed_at.localtime.strftime('%d/%m/%Y') : '' },
dossier_termine_only: true, is_legacy: true }]
super + [{ libelle: 'lien dossier', description: '', lambda: -> (d) { users_dossier_recapitulatif_link(d) } }]
end
def users_dossier_recapitulatif_link(dossier)

View file

@ -3,7 +3,7 @@ require 'spec_helper'
describe 'admin/mail_templates/edit.html.haml', type: :view do
let(:procedure) { create(:procedure) }
let(:mail_template) { create(:mail_template, procedure: procedure) }
let(:all_tags) { mail_template.tags(reject_legacy: false) }
let(:all_tags) { mail_template.tags }
before do
allow(view).to receive(:admin_procedure_mail_template_path).and_return("/toto")
@ -12,15 +12,8 @@ describe 'admin/mail_templates/edit.html.haml', type: :view do
assign(:mail_template, mail_template)
end
subject { render }
context "Legacy champs are not listed in the page" do
it { expect(all_tags).to include(include({ libelle: 'numero_dossier', is_legacy: true })) }
it { is_expected.not_to include("numero_dossier") }
end
context "Non-legacy champs are listed in the page" do
context "Champs are listed in the page" do
it { expect(all_tags).to include(include({ libelle: 'numéro du dossier' })) }
it { is_expected.to include("numéro du dossier") }
it { expect(render).to include("numéro du dossier") }
end
end