Spec: specify locked logic

This commit is contained in:
simon lehericey 2019-08-16 14:17:39 +02:00
parent 1b14d85c77
commit 08bb393ced
2 changed files with 22 additions and 0 deletions

View file

@ -36,6 +36,17 @@ describe Users::SessionsController, type: :controller do
expect(response).to redirect_to(stored_path)
end
end
context 'when the user is locked' do
before { user.lock_access! }
it 'redirects to new_path' do
subject
expect(response).to redirect_to(new_user_session_path)
expect(flash.alert).to eq(I18n.t('devise.failure.invalid'))
end
end
end
context 'when the credentials are wrong' do

View file

@ -13,6 +13,17 @@ feature 'Signin in:' do
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 }