2015-09-22 10:15:12 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
2017-07-18 15:26:33 +02:00
|
|
|
let(:procedure) { create(:procedure, :published) }
|
2017-06-12 16:12:03 +02:00
|
|
|
let!(:dossier) { create(:dossier, procedure: procedure) }
|
2015-09-22 10:15:12 +02:00
|
|
|
before do
|
|
|
|
visit backoffice_path
|
|
|
|
end
|
|
|
|
scenario 'he is redirected to /gestionnaires/sign_id' do
|
2017-01-03 11:40:47 +01:00
|
|
|
expect(page).to have_css('#user_email')
|
2015-09-22 10:15:12 +02:00
|
|
|
end
|
|
|
|
context 'when user enter bad credentials' do
|
|
|
|
before do
|
2017-01-03 11:32:21 +01:00
|
|
|
page.find_by_id(:user_email).set 'unknown@plop.com'
|
|
|
|
page.find_by_id(:user_password).set 'password'
|
2015-09-22 10:15:12 +02:00
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
|
|
|
scenario 'he stay on the same page with an error' do
|
2017-01-03 11:40:47 +01:00
|
|
|
expect(page).to have_content('Mauvais couple login / mot de passe')
|
2015-09-22 10:15:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
context 'when user enter good credentials' do
|
2015-11-10 11:58:56 +01:00
|
|
|
let(:administrateur) { create(:administrateur) }
|
2016-05-20 15:39:17 +02:00
|
|
|
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
|
2015-11-10 11:58:56 +01:00
|
|
|
|
2015-09-22 10:15:12 +02:00
|
|
|
before do
|
2016-12-13 16:10:03 +01:00
|
|
|
create :assign_to, gestionnaire: gestionnaire, procedure: procedure
|
2017-06-12 16:12:03 +02:00
|
|
|
page.find_by_id(:user_email).set gestionnaire.email
|
|
|
|
page.find_by_id(:user_password).set gestionnaire.password
|
2015-09-22 10:15:12 +02:00
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
2017-12-19 15:08:08 +01:00
|
|
|
scenario 'he is redirected to /procedures' do
|
|
|
|
expect(current_path).to eq(procedures_path)
|
2015-09-22 10:15:12 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-13 16:10:03 +01:00
|
|
|
end
|