Merge pull request #489 from sgmap/fix-183

[Fix #183] Display “oui” or “non” instead of “true” or “false”
This commit is contained in:
gregoirenovel 2017-06-27 10:53:25 +02:00 committed by GitHub
commit eb0ddbdba6
4 changed files with 77 additions and 13 deletions

View file

@ -46,6 +46,11 @@
= dossier.text_summary = dossier.text_summary
- else - else
Pas de dossier associé Pas de dossier associé
- elsif champ.type_champ == 'yes_no'
- if champ.decorate.value == 'true'
Oui
- elsif champ.decorate.value == 'false'
Non
- else - else
= champ.decorate.value.html_safe = champ.decorate.value.html_safe

View file

@ -75,6 +75,14 @@ FactoryGirl.define do
end end
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 trait :with_two_type_de_piece_justificative do
after(:build) do |procedure, _evaluator| after(:build) do |procedure, _evaluator|
rib = create(:type_de_piece_justificative, :rib, order_place: 1) rib = create(:type_de_piece_justificative, :rib, order_place: 1)

View file

@ -14,5 +14,10 @@ FactoryGirl.define do
libelle 'Référence autre dossier' libelle 'Référence autre dossier'
type_champ 'dossier_link' type_champ 'dossier_link'
end end
trait :type_yes_no do
libelle 'Yes/no'
type_champ 'yes_no'
end
end end
end end

View file

@ -1,6 +1,7 @@
require 'spec_helper' require 'spec_helper'
describe 'dossiers/_infos_dossier.html.haml', type: :view do 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)) } let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
before do before do
@ -23,3 +24,48 @@ describe 'dossiers/_infos_dossier.html.haml', type: :view do
it { expect(rendered).to have_content(champs.last.value) } it { expect(rendered).to have_content(champs.last.value) }
end end
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