DossierControllerSpec: refactor by remove sign_in test logic

As this test belongs to ProcedureControllerSpec
This commit is contained in:
Simon Lehericey 2017-07-26 14:33:48 +02:00 committed by Mathieu Magnin
parent f6bc9ec852
commit 62894175ae

View file

@ -5,9 +5,9 @@ describe NewGestionnaire::DossiersController, type: :controller do
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
describe '#attestation' do
before { sign_in(gestionnaire) }
describe '#attestation' do
context 'when a dossier has an attestation' do
let(:fake_pdf) { double(read: 'pdf content') }
let!(:dossier) { create(:dossier, :replied, attestation: Attestation.new, procedure: procedure) }
@ -28,9 +28,6 @@ describe NewGestionnaire::DossiersController, type: :controller do
end
end
context "when gestionnaire is signed in" do
before { sign_in(gestionnaire) }
describe '#follow' do
before do
expect_any_instance_of(Dossier).to receive(:next_step!).with('gestionnaire', 'follow')
@ -74,40 +71,17 @@ describe NewGestionnaire::DossiersController, type: :controller do
it { expect(dossier.archived).to be false }
it { expect(response).to redirect_to(procedures_url) }
end
end
describe "#show" do
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier){ create(:dossier, :replied, procedure: procedure) }
before { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
subject { get :show, params: { procedure_id: procedure.id, dossier_id: dossier.id } }
context "when gestionnaire is not logged in" do
before { subject }
it { expect(response).to redirect_to(new_user_session_path) }
end
context "when gestionnaire is logged in" do
before { sign_in(gestionnaire) }
it do
subject
expect(response).to have_http_status(:success)
end
context "when gestionnaire is not affected on procedure" do
let(:dossier){ create(:dossier, :replied) }
it { expect{ subject }.to raise_error(ActiveRecord::RecordNotFound) }
end
end
it { expect(response).to have_http_status(:success) }
end
describe "#create_commentaire" do
let(:saved_commentaire) { dossier.commentaires.first }
before do
sign_in(gestionnaire)
post :create_commentaire, params: {
procedure_id: procedure.id,
dossier_id: dossier.id,