[Fix #962] In new UI, add link on “dossier_link” field values

This commit is contained in:
gregoirenovel 2017-11-21 17:20:52 +01:00
parent d52726096c
commit 303e5285e9
3 changed files with 29 additions and 2 deletions

View file

@ -15,6 +15,17 @@
- c.value.split(", ").each do |item|
%li
= item
- when "dossier_link"
%th.libelle
= "#{c.libelle} :"
%td.rich-text
- dossier = Dossier.includes(:procedure).find_by(id: c.value)
- if dossier
= link_to("Dossier nº #{dossier.id}", dossier_path(dossier.procedure, dossier), target: '_blank')
%br
= dossier.text_summary
- else
Pas de dossier associé
- else
%th.libelle
= "#{c.libelle} :"

View file

@ -13,5 +13,9 @@ FactoryGirl.define do
trait :explication do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :explication) }
end
trait :dossier_link do
type_de_champ { FactoryGirl.create(:type_de_champ_public, :type_dossier_link) }
end
end
end

View file

@ -1,11 +1,13 @@
describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
before { render 'new_gestionnaire/dossiers/champs.html.haml', champs: champs }
context "there is some champs" do
context "there are some champs" do
let(:dossier) { create(:dossier) }
let(:champ1) { create(:champ, :checkbox, value: "true") }
let(:champ2) { create(:champ, :header_section, value: "Section") }
let(:champ3) { create(:champ, :explication, value: "mazette") }
let(:champs) { [champ1, champ2, champ3] }
let(:champ4) { create(:champ, :dossier_link, value: dossier.id) }
let(:champs) { [champ1, champ2, champ3, champ4] }
it { expect(rendered).to include(champ1.libelle) }
it { expect(rendered).to include(champ1.value) }
@ -15,5 +17,15 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
it { expect(rendered).not_to include(champ3.libelle) }
it { expect(rendered).not_to include(champ3.value) }
it { expect(rendered).to have_link("Dossier nº #{dossier.id}") }
it { expect(rendered).to include(dossier.text_summary) }
end
context "with a dossier_link champ but without value" do
let(:champ) { create(:champ, :dossier_link, value: nil) }
let(:champs) { [champ] }
it { expect(rendered).to include("Pas de dossier associé") }
end
end