[Fix #183] Display “oui” or “non” instead of “true” or “false”
This commit is contained in:
parent
859a821ee7
commit
0e3ebfd819
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,25 +1,71 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe 'dossiers/_infos_dossier.html.haml', type: :view do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
|
||||
describe "champs rendering" do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, procedure: create(:procedure, :with_api_carto, :with_type_de_champ)) }
|
||||
|
||||
before do
|
||||
champs.each do |champ|
|
||||
champ.value = ((0...8).map { (65 + rand(26)).chr }.join)
|
||||
champ.save
|
||||
before do
|
||||
champs.each do |champ|
|
||||
champ.value = ((0...8).map { (65 + rand(26)).chr }.join)
|
||||
champ.save
|
||||
end
|
||||
|
||||
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
|
||||
render
|
||||
end
|
||||
|
||||
assign(:facade, DossierFacades.new(dossier.id, dossier.user.email))
|
||||
render
|
||||
describe 'every champs are present on the page' do
|
||||
let(:champs) { dossier.champs }
|
||||
|
||||
it { expect(rendered).to have_content(champs.first.libelle) }
|
||||
it { expect(rendered).to have_content(champs.first.value) }
|
||||
|
||||
it { expect(rendered).to have_content(champs.last.libelle) }
|
||||
it { expect(rendered).to have_content(champs.last.value) }
|
||||
end
|
||||
end
|
||||
|
||||
describe 'every champs are present on the page' do
|
||||
let(:champs) { dossier.champs }
|
||||
describe "oui_non champ rendering" do
|
||||
let(:dossier_with_yes_no) { create(:dossier, procedure: create(:procedure, :with_yes_no)) }
|
||||
|
||||
it { expect(rendered).to have_content(champs.first.libelle) }
|
||||
it { expect(rendered).to have_content(champs.first.value) }
|
||||
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
|
||||
|
||||
it { expect(rendered).to have_content(champs.last.libelle) }
|
||||
it { expect(rendered).to have_content(champs.last.value) }
|
||||
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