2019-08-12 10:35:43 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
feature 'As an administrateur', js: true do
|
|
|
|
let(:administration) { create(:administration) }
|
|
|
|
let(:admin_email) { 'new_admin@gouv.fr' }
|
2019-10-24 11:41:01 +02:00
|
|
|
let(:new_admin) { Administrateur.find_by(email: admin_email) }
|
2019-08-12 10:35:43 +02:00
|
|
|
|
|
|
|
before do
|
|
|
|
perform_enqueued_jobs do
|
|
|
|
administration.invite_admin(admin_email)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'I can register' do
|
2019-10-24 11:41:01 +02:00
|
|
|
expect(new_admin.reload.active?).to be(false)
|
|
|
|
|
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}"
|
|
|
|
fill_in :administrateur_password, with: 'démarches-simplifiées-pwd'
|
|
|
|
|
|
|
|
click_button 'Continuer'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Mot de passe enregistré'
|
2019-10-24 11:41:01 +02:00
|
|
|
|
|
|
|
expect(new_admin.reload.active?).to be(true)
|
2019-08-12 10:35:43 +02:00
|
|
|
end
|
|
|
|
end
|