2015-11-13 15:23:21 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe BackofficeController, type: :controller do
|
|
|
|
describe 'GET #index' do
|
2017-04-27 12:17:50 +02:00
|
|
|
context 'when gestionnaire is not connected' do
|
2015-11-13 15:23:21 +01:00
|
|
|
before do
|
|
|
|
get :index
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response).to redirect_to :new_gestionnaire_session }
|
|
|
|
end
|
|
|
|
|
2017-04-27 12:17:50 +02:00
|
|
|
context 'when gestionnaire is connected' do
|
2015-11-13 15:23:21 +01:00
|
|
|
before do
|
|
|
|
sign_in create(:gestionnaire)
|
|
|
|
get :index
|
|
|
|
end
|
|
|
|
|
2015-12-02 18:03:52 +01:00
|
|
|
it { expect(response).to redirect_to :backoffice_dossiers }
|
2015-11-13 15:23:21 +01:00
|
|
|
end
|
|
|
|
end
|
2017-04-27 12:17:50 +02:00
|
|
|
|
|
|
|
describe 'GET #invitations' do
|
|
|
|
context 'when gestionnaire is not invited on any dossiers' do
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in create(:gestionnaire)
|
|
|
|
get :invitations
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.status).to eq(200) }
|
|
|
|
it { expect(response.body).to include("INVITATIONS") }
|
|
|
|
it { expect(response.body).to include("0 avis à rendre") }
|
|
|
|
it { expect(response.body).to include("0 avis rendus") }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when gestionnaire is invited on a dossier' do
|
|
|
|
let(:dossier){ create(:dossier) }
|
|
|
|
let(:gestionnaire){ create(:gestionnaire) }
|
|
|
|
let!(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire) }
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in gestionnaire
|
|
|
|
get :invitations
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.status).to eq(200) }
|
|
|
|
it { expect(response.body).to include("1 avis à rendre") }
|
|
|
|
it { expect(response.body).to include("0 avis rendus") }
|
|
|
|
it { expect(response.body).to include(dossier.procedure.libelle) }
|
|
|
|
|
|
|
|
context 'when avis is already sent' do
|
|
|
|
let!(:avis){ create(:avis, dossier: dossier, gestionnaire: gestionnaire, answer: "Voici mon avis.") }
|
|
|
|
|
|
|
|
it { expect(response.body).to include("0 avis à rendre") }
|
|
|
|
it { expect(response.body).to include("1 avis rendu") }
|
|
|
|
it { expect(response.body).to include(dossier.procedure.libelle) }
|
|
|
|
end
|
2017-08-24 16:26:57 +02:00
|
|
|
|
|
|
|
context 'when dossier linked to avis is hidden' do
|
|
|
|
before do
|
|
|
|
dossier.update_attributes(hidden_at: Time.now)
|
|
|
|
get :invitations
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(response.status).to eq(200) }
|
|
|
|
it { expect(response.body).to include("0 avis à rendre") }
|
|
|
|
it { expect(response.body).to include("0 avis rendu") }
|
|
|
|
end
|
2017-04-27 12:17:50 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-13 16:10:03 +01:00
|
|
|
end
|