2021-10-26 11:44:53 +02:00
|
|
|
describe 'As an administrateur', js: true do
|
2020-11-05 15:09:11 +01:00
|
|
|
let(:super_admin) { create(:super_admin) }
|
2019-08-12 10:35:43 +02:00
|
|
|
let(:admin_email) { 'new_admin@gouv.fr' }
|
2020-01-30 17:08:09 +01:00
|
|
|
let(:new_admin) { Administrateur.by_email(admin_email) }
|
2021-08-31 18:15:08 +02:00
|
|
|
let(:weak_password) { '12345678' }
|
|
|
|
let(:strong_password) { 'a new, long, and complicated password!' }
|
2019-08-12 10:35:43 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
perform_enqueued_jobs do
|
2020-11-05 15:09:11 +01:00
|
|
|
super_admin.invite_admin(admin_email)
|
2019-08-12 10:35:43 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-08-31 18:15:08 +02:00
|
|
|
scenario 'I can register', js: true do
|
2019-11-05 10:05:59 +01:00
|
|
|
expect(new_admin.reload.user.active?).to be(false)
|
2019-10-24 11:41:01 +02:00
|
|
|
|
2019-08-12 10:35:43 +02:00
|
|
|
confirmation_email = open_email(admin_email)
|
|
|
|
token_params = confirmation_email.body.match(/token=[^"]+/)
|
|
|
|
|
|
|
|
visit "admin/activate?#{token_params}"
|
2021-08-31 18:15:08 +02:00
|
|
|
fill_in :administrateur_password, with: weak_password
|
|
|
|
|
|
|
|
expect(page).to have_text('Mot de passe très vulnérable')
|
|
|
|
expect(page).to have_button('Continuer', disabled: true)
|
|
|
|
|
|
|
|
fill_in :administrateur_password, with: strong_password
|
|
|
|
expect(page).to have_text('Mot de passe suffisamment fort et sécurisé')
|
|
|
|
expect(page).to have_button('Continuer', disabled: false)
|
2019-08-12 10:35:43 +02:00
|
|
|
|
|
|
|
click_button 'Continuer'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Mot de passe enregistré'
|
2019-10-24 11:41:01 +02:00
|
|
|
|
2019-11-05 10:05:59 +01:00
|
|
|
expect(new_admin.reload.user.active?).to be(true)
|
2019-08-12 10:35:43 +02:00
|
|
|
end
|
|
|
|
end
|