2015-09-22 10:15:12 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'when gestionnaire come to /backoffice and is not authenticated' do
|
2015-09-22 11:56:14 +02:00
|
|
|
let(:procedure) { create(:procedure) }
|
2016-01-18 17:18:04 +01: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
|
|
|
|
expect(page).to have_css('#gestionnaire_login')
|
|
|
|
end
|
|
|
|
context 'when user enter bad credentials' do
|
|
|
|
before do
|
|
|
|
page.find_by_id(:gestionnaire_email).set 'unknown@plop.com'
|
|
|
|
page.find_by_id(:gestionnaire_password).set 'password'
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
|
|
|
scenario 'he stay on the same page with an error' do
|
|
|
|
expect(page).to have_content('email ou mot de passe incorrect.')
|
|
|
|
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
|
|
|
|
page.find_by_id(:gestionnaire_email).set gestionnaire.email
|
|
|
|
page.find_by_id(:gestionnaire_password).set gestionnaire.password
|
|
|
|
page.click_on 'Se connecter'
|
|
|
|
end
|
|
|
|
scenario 'he is redirected to /backoffice' do
|
2015-12-02 18:03:52 +01:00
|
|
|
expect(page).to have_css('#backoffice_index')
|
2015-09-22 10:15:12 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|