9fd38cae5e
System specs have been available since Rails 5.1, and are better integrated with the Rails framework. - Rename `spec/features` to `spec/system` - Rename `feature do` to `describe do` - Configure Capybara for system specs Steps mostly taken from https://medium.com/table-xi/a-quick-guide-to-rails-system-tests-in-rspec-b6e9e8a8b5f6
36 lines
1.2 KiB
Ruby
36 lines
1.2 KiB
Ruby
describe '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) }
|
|
let(:weak_password) { '12345678' }
|
|
let(:strong_password) { 'a new, long, and complicated password!' }
|
|
|
|
before do
|
|
perform_enqueued_jobs do
|
|
super_admin.invite_admin(admin_email)
|
|
end
|
|
end
|
|
|
|
scenario 'I can register', js: true 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: 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)
|
|
|
|
click_button 'Continuer'
|
|
|
|
expect(page).to have_content 'Mot de passe enregistré'
|
|
|
|
expect(new_admin.reload.user.active?).to be(true)
|
|
end
|
|
end
|