Remove previous attempt but steal its spec
This commit is contained in:
parent
376013ef03
commit
594cda3ee3
3 changed files with 133 additions and 173 deletions
|
@ -1030,136 +1030,4 @@ describe Procedure do
|
|||
it { is_expected.to be false }
|
||||
end
|
||||
end
|
||||
|
||||
describe "#dossiers_count_for_instructeur" do
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let(:procedure) { create(:procedure, instructeurs: [instructeur]) }
|
||||
let(:gi_2) { procedure.groupe_instructeurs.create(label: '2') }
|
||||
let(:gi_3) { procedure.groupe_instructeurs.create(label: '3') }
|
||||
|
||||
subject do
|
||||
procedure.dossiers_count_for_instructeur(instructeur)
|
||||
end
|
||||
|
||||
context "when logged in, and belonging to gi_1, gi_2" do
|
||||
before do
|
||||
instructeur.groupe_instructeurs << gi_2
|
||||
end
|
||||
|
||||
context "without any dossier" do
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(0) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
end
|
||||
|
||||
context 'with a new brouillon dossier' do
|
||||
let!(:brouillon_dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(0) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
end
|
||||
|
||||
context 'with a new dossier without follower' do
|
||||
let!(:new_unfollow_dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(1) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(1) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
|
||||
context 'and dossiers without follower on each of the others groups' do
|
||||
let!(:new_unfollow_dossier_on_gi_2) { create(:dossier, :en_instruction, groupe_instructeur: gi_2) }
|
||||
let!(:new_unfollow_dossier_on_gi_3) { create(:dossier, :en_instruction, groupe_instructeur: gi_3) }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(2) }
|
||||
it { expect(subject['total']).to eq(2) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a new dossier with a follower' do
|
||||
let!(:new_followed_dossier) { create(:dossier, :en_instruction, procedure: procedure) }
|
||||
|
||||
before do
|
||||
instructeur.followed_dossiers << new_followed_dossier
|
||||
end
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(1) }
|
||||
it { expect(subject['termines']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(1) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
|
||||
context 'and dossier with a follower on each of the others groups' do
|
||||
let!(:new_follow_dossier_on_gi_2) { create(:dossier, :en_instruction, groupe_instructeur: gi_2) }
|
||||
let!(:new_follow_dossier_on_gi_3) { create(:dossier, :en_instruction, groupe_instructeur: gi_3) }
|
||||
|
||||
before do
|
||||
instructeur.followed_dossiers << new_follow_dossier_on_gi_2 << new_follow_dossier_on_gi_3
|
||||
end
|
||||
|
||||
# followed dossiers on another groupe should not be displayed
|
||||
it { expect(subject['suivis']).to eq(2) }
|
||||
it { expect(subject['total']).to eq(2) }
|
||||
end
|
||||
|
||||
context 'and dossier with a follower is unfollowed' do
|
||||
before do
|
||||
instructeur.unfollow(new_followed_dossier)
|
||||
end
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(1) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(1) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with a termine dossier' do
|
||||
let!(:termine_dossier) { create(:dossier, :accepte, procedure: procedure) }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(1) }
|
||||
it { expect(subject['total']).to eq(1) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
|
||||
context 'and terminer dossiers on each of the others groups' do
|
||||
let!(:termine_dossier_on_gi_2) { create(:dossier, :accepte, groupe_instructeur: gi_2) }
|
||||
let!(:termine_dossier_on_gi_3) { create(:dossier, :accepte, groupe_instructeur: gi_3) }
|
||||
|
||||
before { subject }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(2) }
|
||||
it { expect(subject['total']).to eq(2) }
|
||||
it { expect(subject['archived']).to eq(0) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'with an archived dossier' do
|
||||
let!(:archived_dossier) { create(:dossier, :en_instruction, procedure: procedure, archived: true) }
|
||||
|
||||
it { expect(subject['a_suivre']).to eq(0) }
|
||||
it { expect(subject['suivis']).to eq(0) }
|
||||
it { expect(subject['termines']).to eq(0) }
|
||||
it { expect(subject['total']).to eq(0) }
|
||||
it { expect(subject['archived']).to eq(1) }
|
||||
|
||||
context 'and terminer dossiers on each of the others groups' do
|
||||
let!(:archived_dossier_on_gi_2) { create(:dossier, :en_instruction, groupe_instructeur: gi_2, archived: true) }
|
||||
let!(:archived_dossier_on_gi_3) { create(:dossier, :en_instruction, groupe_instructeur: gi_3, archived: true) }
|
||||
|
||||
it { expect(subject['archived']).to eq(2) }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue