2016-05-24 16:39:39 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Admin::AccompagnateursController, type: :controller do
|
|
|
|
let(:admin) { create(:administrateur) }
|
|
|
|
let(:procedure) { create :procedure, administrateur: admin }
|
|
|
|
let(:gestionnaire) { create :gestionnaire, administrateurs: [admin] }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in admin
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'GET #show' do
|
|
|
|
subject { get :show, procedure_id: procedure.id }
|
|
|
|
it { expect(subject.status).to eq(200) }
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'PUT #update' do
|
2016-09-08 16:21:54 +02:00
|
|
|
subject { put :update, accompagnateur_id: gestionnaire.id ,procedure_id: procedure.id, to: 'assign' }
|
2016-05-24 16:39:39 +02:00
|
|
|
|
|
|
|
it { expect(subject).to redirect_to admin_procedure_accompagnateurs_path(procedure_id: procedure.id) }
|
|
|
|
|
|
|
|
context 'when assignement is valid' do
|
|
|
|
before do
|
|
|
|
subject
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect(flash[:notice]).to be_present }
|
2016-09-08 16:21:54 +02:00
|
|
|
|
|
|
|
it 'default pref list dossier procedure columns are created' do
|
|
|
|
expect(procedure.preference_list_dossiers.size).to eq gestionnaire.preference_list_dossiers.where('procedure_id IS NULL').size
|
|
|
|
end
|
2016-05-24 16:39:39 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|