demarches-normaliennes/spec/features/backoffice/connection_spec.rb

37 lines
1.3 KiB
Ruby
Raw Normal View History

2015-09-22 10:15:12 +02:00
require 'spec_helper'
feature 'when gestionnaire come to /backoffice and is not authenticated' do
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
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
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
let(:administrateur) { create(:administrateur) }
let(:gestionnaire) { create(:gestionnaire, administrateurs: [administrateur]) }
2015-09-22 10:15:12 +02:00
before do
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
scenario 'he is redirected to /procedures' do
expect(current_path).to eq(procedures_path)
2015-09-22 10:15:12 +02:00
end
end
end