demarches-normaliennes/spec/features/admin/admin_creation_spec.rb
2020-11-05 16:03:55 +01:00

27 lines
758 B
Ruby

feature 'As an administrateur', js: true do
let(:super_admin) { create(:super_admin) }
let(:admin_email) { 'new_admin@gouv.fr' }
let(:new_admin) { Administrateur.by_email(admin_email) }
before do
perform_enqueued_jobs do
super_admin.invite_admin(admin_email)
end
end
scenario 'I can register' do
expect(new_admin.reload.user.active?).to be(false)
confirmation_email = open_email(admin_email)
token_params = confirmation_email.body.match(/token=[^"]+/)
visit "admin/activate?#{token_params}"
fill_in :administrateur_password, with: 'my-s3cure-p4ssword'
click_button 'Continuer'
expect(page).to have_content 'Mot de passe enregistré'
expect(new_admin.reload.user.active?).to be(true)
end
end