Add on gestionnaire dossier view the private form
This commit is contained in:
parent
ddb64878c8
commit
480431ea01
28 changed files with 320 additions and 88 deletions
7
spec/models/champ_private_spec.rb
Normal file
7
spec/models/champ_private_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ChampPrivate do
|
||||
require 'models/champ_shared_example.rb'
|
||||
|
||||
it_should_behave_like "champ_spec"
|
||||
end
|
7
spec/models/champ_public_spec.rb
Normal file
7
spec/models/champ_public_spec.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ChampPublic do
|
||||
require 'models/champ_shared_example.rb'
|
||||
|
||||
it_should_behave_like "champ_spec"
|
||||
end
|
38
spec/models/champ_shared_example.rb
Normal file
38
spec/models/champ_shared_example.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
shared_examples 'champ_spec' do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:value) }
|
||||
end
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:type_champ).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'data_provide' do
|
||||
let(:champ) { create :champ }
|
||||
|
||||
subject { champ.data_provide }
|
||||
|
||||
context 'when type_champ is datetime' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'datetime'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'datepicker' }
|
||||
end
|
||||
|
||||
context 'when type_champ is address' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'address'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'typeahead' }
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,40 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Champ do
|
||||
describe 'database columns' do
|
||||
it { is_expected.to have_db_column(:value) }
|
||||
end
|
||||
require 'models/champ_shared_example.rb'
|
||||
|
||||
describe 'associations' do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
it { is_expected.to belong_to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'delegation' do
|
||||
it { is_expected.to delegate_method(:libelle).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:type_champ).to(:type_de_champ) }
|
||||
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
|
||||
end
|
||||
|
||||
describe 'data_provide' do
|
||||
let(:champ) { create :champ }
|
||||
|
||||
subject { champ.data_provide }
|
||||
|
||||
context 'when type_champ is datetime' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'datetime'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'datepicker' }
|
||||
end
|
||||
|
||||
context 'when type_champ is address' do
|
||||
before do
|
||||
champ.type_de_champ = create :type_de_champ_public, type_champ: 'address'
|
||||
end
|
||||
|
||||
it { is_expected.to eq 'typeahead' }
|
||||
end
|
||||
end
|
||||
it_should_behave_like "champ_spec"
|
||||
end
|
|
@ -92,12 +92,16 @@ describe Dossier do
|
|||
end
|
||||
|
||||
describe '#build_default_champs' do
|
||||
context 'when dossier is linked to a procedure' do
|
||||
context 'when dossier is linked to a procedure with type_de_champ_public and private' do
|
||||
let(:dossier) { create(:dossier, user: user) }
|
||||
|
||||
it 'build all champs needed' do
|
||||
expect(dossier.champs.count).to eq(1)
|
||||
end
|
||||
|
||||
it 'build all champs_private needed' do
|
||||
expect(dossier.champs_private.count).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -604,7 +608,7 @@ describe Dossier do
|
|||
|
||||
subject { dossier.ordered_champs }
|
||||
|
||||
it { expect(Champ.where(dossier_id: 0).size).to eq 5 }
|
||||
it { expect(ChampPublic.where(dossier_id: 0).size).to eq 5 }
|
||||
|
||||
describe 'for dossier 1' do
|
||||
let(:dossier) { dossier_1 }
|
||||
|
@ -626,6 +630,48 @@ describe Dossier do
|
|||
|
||||
end
|
||||
|
||||
describe '#ordered_champs_private' do
|
||||
let!(:procedure_1) { create :procedure }
|
||||
let!(:procedure_2) { create :procedure }
|
||||
|
||||
let(:dossier_1) { Dossier.new(id: 0, procedure: procedure_1) }
|
||||
let(:dossier_2) { Dossier.new(id: 0, procedure: procedure_2) }
|
||||
|
||||
before do
|
||||
create :type_de_champ_private, libelle: 'type_1_1', order_place: 1, procedure: dossier_1.procedure
|
||||
create :type_de_champ_private, libelle: 'type_1_2', order_place: 2, procedure: dossier_1.procedure
|
||||
|
||||
create :type_de_champ_private, libelle: 'type_2_1', order_place: 1, procedure: dossier_2.procedure
|
||||
create :type_de_champ_private, libelle: 'type_2_2', order_place: 2, procedure: dossier_2.procedure
|
||||
create :type_de_champ_private, libelle: 'type_2_3', order_place: 3, procedure: dossier_2.procedure
|
||||
|
||||
dossier_1.build_default_champs
|
||||
dossier_2.build_default_champs
|
||||
end
|
||||
|
||||
subject { dossier.ordered_champs_private }
|
||||
|
||||
it { expect(ChampPrivate.where(dossier_id: 0).size).to eq 5 }
|
||||
|
||||
describe 'for dossier 1' do
|
||||
let(:dossier) { dossier_1 }
|
||||
|
||||
it { expect(subject.size).to eq 2 }
|
||||
it { expect(subject.first.type_de_champ.libelle).to eq 'type_1_1' }
|
||||
it { expect(subject.last.type_de_champ.libelle).to eq 'type_1_2' }
|
||||
end
|
||||
|
||||
describe 'for dossier 2' do
|
||||
let(:dossier) { dossier_2 }
|
||||
|
||||
it { expect(subject.size).to eq 3 }
|
||||
|
||||
it { expect(subject.first.type_de_champ.libelle).to eq 'type_2_1' }
|
||||
it { expect(subject.second.type_de_champ.libelle).to eq 'type_2_2' }
|
||||
it { expect(subject.last.type_de_champ.libelle).to eq 'type_2_3' }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#total_follow' do
|
||||
let(:dossier) { create(:dossier, :with_entreprise, user: user) }
|
||||
let(:dossier2) { create(:dossier, :with_entreprise, user: user) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue