2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-11-06 15:15:51 +01:00
|
|
|
describe 'As an instructeur', js: true do
|
2019-08-12 16:27:53 +02:00
|
|
|
let(:administrateur) { create(:administrateur, :with_procedure) }
|
|
|
|
let(:procedure) { administrateur.procedures.first }
|
|
|
|
let(:instructeur_email) { 'new_instructeur@gouv.fr' }
|
|
|
|
|
|
|
|
before do
|
2019-08-14 12:15:13 +02:00
|
|
|
login_as administrateur.user, scope: :user
|
2019-08-12 16:27:53 +02:00
|
|
|
|
2021-08-31 22:54:45 +02:00
|
|
|
visit admin_procedure_path(procedure)
|
|
|
|
find('#groupe-instructeurs').click
|
2019-08-12 16:27:53 +02:00
|
|
|
|
2022-01-05 11:46:49 +01:00
|
|
|
fill_in 'Emails', with: instructeur_email
|
2021-08-31 22:54:45 +02:00
|
|
|
perform_enqueued_jobs { click_on 'Affecter' }
|
|
|
|
|
|
|
|
expect(page).to have_text("Les instructeurs ont bien été affectés à la démarche")
|
2019-08-12 16:27:53 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
scenario 'I can register' do
|
2023-02-17 15:24:12 +01:00
|
|
|
confirmation_email = emails_sent_to(instructeur_email).first
|
2019-08-12 16:27:53 +02:00
|
|
|
token_params = confirmation_email.body.match(/token=[^"]+/)
|
|
|
|
|
|
|
|
visit "users/activate?#{token_params}"
|
2023-03-03 14:16:15 +01:00
|
|
|
fill_in :user_password, with: SECURE_PASSWORD
|
2019-08-12 16:27:53 +02:00
|
|
|
|
|
|
|
click_button 'Définir le mot de passe'
|
|
|
|
|
|
|
|
expect(page).to have_content 'Mot de passe enregistré'
|
|
|
|
end
|
|
|
|
end
|