Merge pull request #489 from sgmap/fix-183
[Fix #183] Display “oui” or “non” instead of “true” or “false”
This commit is contained in:
commit
eb0ddbdba6
4 changed files with 77 additions and 13 deletions
|
@ -46,6 +46,11 @@
|
|||
= dossier.text_summary
|
||||
- else
|
||||
Pas de dossier associé
|
||||
- elsif champ.type_champ == 'yes_no'
|
||||
- if champ.decorate.value == 'true'
|
||||
Oui
|
||||
- elsif champ.decorate.value == 'false'
|
||||
Non
|
||||
- else
|
||||
= champ.decorate.value.html_safe
|
||||
|
||||
|
|
|
@ -75,6 +75,14 @@ FactoryGirl.define do
|
|||
end
|
||||
end
|
||||
|
||||
trait :with_yes_no do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
type_de_champ = create(:type_de_champ_public, :type_yes_no)
|
||||
|
||||
procedure.types_de_champ << type_de_champ
|
||||
end
|
||||
end
|
||||
|
||||
trait :with_two_type_de_piece_justificative do
|
||||
after(:build) do |procedure, _evaluator|
|
||||
rib = create(:type_de_piece_justificative, :rib, order_place: 1)
|
||||
|
|
|
@ -14,5 +14,10 @@ FactoryGirl.define do
|
|||
libelle 'Référence autre dossier'
|
||||
type_champ 'dossier_link'
|
||||
end
|
||||
|
||||
trait :type_yes_no do
|
||||
libelle 'Yes/no'
|
||||
type_champ 'yes_no'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
||||
describe "champs rendering" do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
|
||||
|
||||
before do
|
||||
|
@ -22,4 +23,49 @@ describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
|||
it { expect(rendered).to have_content(champs.last.libelle) }
|
||||
it { expect(rendered).to have_content(champs.last.value) }
|
||||
end
|
||||
end
|
||||
|
||||
describe "oui_non champ rendering" do
|
||||
let(:dossier_with_yes_no) { create(:dossier, procedure: create(:procedure, :with_yes_no)) }
|
||||
|
||||
context "with the true value" do
|
||||
before do
|
||||
oui_non_champ = dossier_with_yes_no.champs.first
|
||||
oui_non_champ.value = 'true'
|
||||
oui_non_champ.save
|
||||
|
||||
assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content("Oui") }
|
||||
end
|
||||
|
||||
context "with the false value" do
|
||||
before do
|
||||
oui_non_champ = dossier_with_yes_no.champs.first
|
||||
oui_non_champ.value = 'false'
|
||||
oui_non_champ.save
|
||||
|
||||
assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).to have_content("Non") }
|
||||
end
|
||||
|
||||
context "with no value" do
|
||||
before do
|
||||
oui_non_champ = dossier_with_yes_no.champs.first
|
||||
oui_non_champ.value = nil
|
||||
oui_non_champ.save
|
||||
|
||||
assign(:facade, DossierFacades.new(dossier_with_yes_no.id, dossier_with_yes_no.user.email))
|
||||
render
|
||||
end
|
||||
|
||||
it { expect(rendered).not_to have_content("Oui") }
|
||||
it { expect(rendered).not_to have_content("Non") }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue