4cb747fdb6
Test helpers are separated between two files: spec_helper and rails_helper. This separation is meant to allow tests that do not require Rails (like testing standalone libs) to boot faster. The spec_helper file is always loaded, through `--require spec_helper` in the `.rspec` config file. When needed, the rails_helper file is expected to be required manually. This is fine, but: - Many test files have a redundant `require 'spec_helper'` line; - Many test files should require `rails_helper`, but don't. Not requiring `rails_helper` will cause the Rails-concerned section of the test environment not to be configured–which may cause subtle bugs (like the test database not being properly initialized). Moreover, Spring loads all the Rails files on preloading anyway. So the gains from using only `spec_helper` are thin. To streamline this process, this commit: - Configures `.rspec` to require `rails_helper` by default; - Remove all manual requires to spec_helper or rails_helper. Reference: https://stackoverflow.com/questions/24145329/how-is-spec-rails-helper-rb-different-from-spec-spec-helper-rb-do-i-need-it
66 lines
2.1 KiB
Ruby
66 lines
2.1 KiB
Ruby
feature 'Signin in:' do
|
||
let!(:user) { create(:user, password: password) }
|
||
let(:password) { 'démarches-simplifiées-pwd' }
|
||
|
||
scenario 'an existing user can sign-in' do
|
||
visit root_path
|
||
click_on 'Connexion'
|
||
|
||
sign_in_with user.email, password
|
||
|
||
expect(page).to have_current_path dossiers_path
|
||
end
|
||
|
||
scenario 'an existing user can lock its account' do
|
||
visit root_path
|
||
click_on 'Connexion'
|
||
|
||
5.times { sign_in_with user.email, 'bad password' }
|
||
expect(user.reload.access_locked?).to be false
|
||
|
||
sign_in_with user.email, 'bad password'
|
||
expect(user.reload.access_locked?).to be true
|
||
end
|
||
|
||
context 'when visiting a procedure' do
|
||
let(:procedure) { create :simple_procedure, :with_service }
|
||
|
||
before do
|
||
visit commencer_path(path: procedure.path)
|
||
end
|
||
|
||
scenario 'an existing user can sign-in and fill the procedure' do
|
||
click_on 'J’ai déjà un compte'
|
||
expect(page).to have_current_path new_user_session_path
|
||
expect(page).to have_procedure_description(procedure)
|
||
|
||
sign_in_with user.email, password
|
||
|
||
expect(page).to have_current_path(commencer_path(path: procedure.path))
|
||
click_on 'Commencer la démarche'
|
||
|
||
expect(page).to have_current_path identite_dossier_path(user.reload.dossiers.last)
|
||
expect(page).to have_procedure_description(procedure)
|
||
expect(page).to have_content "Données d'identité"
|
||
end
|
||
end
|
||
|
||
context 'when a user is not confirmed yet' do
|
||
let!(:user) { create(:user, password: password, confirmed_at: nil) }
|
||
|
||
# Ideally, when signing-in with an unconfirmed account,
|
||
# the user would be redirected to the "resend email confirmation" page.
|
||
#
|
||
# However the check for unconfirmed accounts is made by Warden every time a page is loaded –
|
||
# and much earlier than SessionsController#create.
|
||
#
|
||
# For now only test the default behavior (an error message is displayed).
|
||
scenario 'they get an error message' do
|
||
visit root_path
|
||
click_on 'Connexion'
|
||
|
||
sign_in_with user.email, password
|
||
expect(page).to have_content 'Vous devez confirmer votre adresse email pour continuer'
|
||
end
|
||
end
|
||
end
|