2017-04-14 18:10:39 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe DossierTableExportSerializer do
|
2017-12-14 15:51:45 +01:00
|
|
|
describe '#attributes' do
|
|
|
|
subject { DossierTableExportSerializer.new(dossier).serializable_hash }
|
|
|
|
|
|
|
|
context 'when the dossier is en_construction' do
|
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
|
|
|
|
|
|
|
it { is_expected.to include(initiated_at: dossier.en_construction_at) }
|
|
|
|
it { is_expected.to include(state: 'initiated') }
|
|
|
|
end
|
2017-12-14 15:53:02 +01:00
|
|
|
|
|
|
|
context 'when the dossier is en instruction' do
|
|
|
|
let(:dossier) { create(:dossier, :en_instruction) }
|
|
|
|
|
|
|
|
it { is_expected.to include(received_at: dossier.en_instruction_at) }
|
|
|
|
it { is_expected.to include(state: 'received') }
|
|
|
|
end
|
2017-12-04 18:00:12 +01:00
|
|
|
|
|
|
|
context 'when the dossier is accepte' do
|
|
|
|
let(:dossier) { create(:dossier, state: :accepte) }
|
|
|
|
|
|
|
|
it { is_expected.to include(state: 'closed') }
|
|
|
|
end
|
2017-12-04 18:15:40 +01:00
|
|
|
|
|
|
|
context 'when the dossier is refuse' do
|
|
|
|
let(:dossier) { create(:dossier, state: :refuse) }
|
|
|
|
|
|
|
|
it { is_expected.to include(state: 'refused') }
|
|
|
|
end
|
2017-12-04 20:23:57 +01:00
|
|
|
|
|
|
|
context 'when the dossier is sans_suite' do
|
|
|
|
let(:dossier) { create(:dossier, state: :sans_suite) }
|
|
|
|
|
|
|
|
it { is_expected.to include(state: 'without_continuation') }
|
|
|
|
end
|
2017-12-14 15:51:45 +01:00
|
|
|
end
|
|
|
|
|
2017-04-14 18:10:39 +02:00
|
|
|
describe '#emails_accompagnateurs' do
|
|
|
|
let(:gestionnaire){ create(:gestionnaire) }
|
2017-07-18 15:03:08 +02:00
|
|
|
let(:gestionnaire2) { create :gestionnaire}
|
|
|
|
let(:dossier) { create(:dossier) }
|
2017-04-14 18:10:39 +02:00
|
|
|
|
|
|
|
subject { DossierTableExportSerializer.new(dossier).emails_accompagnateurs }
|
|
|
|
|
|
|
|
context 'when there is no accompagnateurs' do
|
|
|
|
it { is_expected.to eq('') }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there one accompagnateur' do
|
2017-07-18 15:03:08 +02:00
|
|
|
before { gestionnaire.followed_dossiers << dossier }
|
2017-04-14 18:10:39 +02:00
|
|
|
|
|
|
|
it { is_expected.to eq(gestionnaire.email) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when there is 2 followers' do
|
2017-07-18 15:03:08 +02:00
|
|
|
before do
|
|
|
|
gestionnaire.followed_dossiers << dossier
|
|
|
|
gestionnaire2.followed_dossiers << dossier
|
|
|
|
end
|
2017-04-14 18:10:39 +02:00
|
|
|
|
|
|
|
it { is_expected.to eq "#{gestionnaire.email} #{gestionnaire2.email}" }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|