Merge pull request #779 from sgmap/exclude-explication

Exclude explication
This commit is contained in:
gregoirenovel 2017-10-05 14:52:02 +02:00 committed by GitHub
commit 51d83bffa7
6 changed files with 34 additions and 9 deletions

View file

@ -215,11 +215,17 @@ class Procedure < ActiveRecord::Base
]
end
types_de_champ.reject { |tdc| tdc.type_champ == 'header_section' }.each do |type_de_champ|
types_de_champ
.reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ ) }
.each do |type_de_champ|
fields << field_hash(type_de_champ.libelle, 'type_de_champ', type_de_champ.id.to_s)
end
types_de_champ_private.reject { |tdc| tdc.type_champ == 'header_section' }.each do |type_de_champ|
types_de_champ_private
.reject { |tdc| ['header_section', 'explication'].include?(tdc.type_champ ) }
.each do |type_de_champ|
fields << field_hash(type_de_champ.libelle, 'type_de_champ_private', type_de_champ.id.to_s)
end

View file

@ -5,7 +5,7 @@
- if c.type_champ == "header_section"
%th.header-section{ colspan: 2 }
= c.libelle
- else
- elsif c.type_champ != "explication"
%th
= "#{c.libelle} :"
%td

View file

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

View file

@ -14,6 +14,10 @@ FactoryGirl.define do
type_champ 'header_section'
end
trait :explication do
type_champ 'explication'
end
trait :type_dossier_link do
libelle 'Référence autre dossier'
type_champ 'dossier_link'

View file

@ -423,11 +423,11 @@ describe Procedure do
end
describe "#fields" do
subject { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, :types_de_champ_count => 2, :types_de_champ_private_count => 2) }
let(:tdc_1) { subject.types_de_champ.first }
let(:tdc_2) { subject.types_de_champ.last }
let(:tdc_private_1) { subject.types_de_champ_private.first }
let(:tdc_private_2) { subject.types_de_champ_private.last }
subject { create(:procedure, :with_type_de_champ, :with_type_de_champ_private, :types_de_champ_count => 4, :types_de_champ_private_count => 4) }
let(:tdc_1) { subject.types_de_champ[0] }
let(:tdc_2) { subject.types_de_champ[1] }
let(:tdc_private_1) { subject.types_de_champ_private[0] }
let(:tdc_private_2) { subject.types_de_champ_private[1] }
let(:expected) {
[
{ "label" => 'Créé le', "table" => 'self', "column" => 'created_at' },
@ -452,6 +452,13 @@ describe Procedure do
]
}
before do
subject.types_de_champ[2].update_attribute(:type_champ, 'header_section')
subject.types_de_champ[3].update_attribute(:type_champ, 'explication')
subject.types_de_champ_private[2].update_attribute(:type_champ, 'header_section')
subject.types_de_champ_private[3].update_attribute(:type_champ, 'explication')
end
it { expect(subject.fields).to eq(expected) }
end

View file

@ -4,12 +4,16 @@ describe 'new_gestionnaire/dossiers/champs.html.haml', type: :view do
context "there is some champs" do
let(:champ1) { create(:champ, :checkbox, value: "true") }
let(:champ2) { create(:champ, :header_section, value: "Section") }
let(:champs) { [champ1, champ2] }
let(:champ3) { create(:champ, :explication, value: "mazette") }
let(:champs) { [champ1, champ2, champ3] }
it { expect(rendered).to include(champ1.libelle) }
it { expect(rendered).to include(champ1.value) }
it { expect(rendered).to have_css(".header-section") }
it { expect(rendered).to include(champ2.libelle) }
it { expect(rendered).not_to include(champ3.libelle) }
it { expect(rendered).not_to include(champ3.value) }
end
end