update tests for rules based routing
This commit is contained in:
parent
25ebfc4928
commit
97aac5d588
5 changed files with 136 additions and 351 deletions
|
@ -1,8 +1,10 @@
|
||||||
describe Administrateurs::GroupeInstructeursController, type: :controller do
|
describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
render_views
|
render_views
|
||||||
|
include Logic
|
||||||
|
|
||||||
let(:admin) { create(:administrateur) }
|
let(:admin) { create(:administrateur) }
|
||||||
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin]) }
|
let(:procedure) { create(:procedure, :published, :for_individual, administrateurs: [admin]) }
|
||||||
|
|
||||||
let!(:gi_1_1) { procedure.defaut_groupe_instructeur }
|
let!(:gi_1_1) { procedure.defaut_groupe_instructeur }
|
||||||
let!(:gi_1_2) { procedure.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
let!(:gi_1_2) { procedure.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
||||||
|
|
||||||
|
@ -193,7 +195,6 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
|
|
||||||
describe '#update' do
|
describe '#update' do
|
||||||
let(:new_name) { 'nouveau nom du groupe' }
|
let(:new_name) { 'nouveau nom du groupe' }
|
||||||
let(:closed_value) { '0' }
|
|
||||||
let!(:procedure_non_routee) { create(:procedure, :published, :for_individual, administrateurs: [admin]) }
|
let!(:procedure_non_routee) { create(:procedure, :published, :for_individual, administrateurs: [admin]) }
|
||||||
let!(:gi_1_1) { procedure_non_routee.defaut_groupe_instructeur }
|
let!(:gi_1_1) { procedure_non_routee.defaut_groupe_instructeur }
|
||||||
|
|
||||||
|
@ -202,7 +203,7 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
params: {
|
params: {
|
||||||
procedure_id: procedure_non_routee.id,
|
procedure_id: procedure_non_routee.id,
|
||||||
id: gi_1_1.id,
|
id: gi_1_1.id,
|
||||||
groupe_instructeur: { label: new_name, closed: closed_value }
|
groupe_instructeur: { label: new_name }
|
||||||
}
|
}
|
||||||
gi_1_1.reload
|
gi_1_1.reload
|
||||||
end
|
end
|
||||||
|
@ -214,18 +215,6 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
expect(flash.notice).to be_present
|
expect(flash.notice).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when we try do disable the default groupe instructeur' do
|
|
||||||
let(:closed_value) { '1' }
|
|
||||||
let!(:gi_1_2) { procedure.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
|
||||||
|
|
||||||
it do
|
|
||||||
expect(subject).to redirect_to admin_procedure_groupe_instructeur_path(procedure_non_routee, gi_1_1)
|
|
||||||
expect(gi_1_1.label).not_to eq(new_name)
|
|
||||||
expect(gi_1_1.closed).to eq(false)
|
|
||||||
expect(flash.alert).to eq('Il est impossible de désactiver le groupe d’instructeurs par défaut.')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'when the name is already taken' do
|
context 'when the name is already taken' do
|
||||||
let!(:gi_1_2) { procedure_non_routee.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
let!(:gi_1_2) { procedure_non_routee.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
||||||
let(:new_name) { gi_1_2.label }
|
let(:new_name) { gi_1_2.label }
|
||||||
|
@ -237,6 +226,45 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#update_state' do
|
||||||
|
let(:closed_value) { '0' }
|
||||||
|
let!(:procedure_non_routee) { create(:procedure, :published, :for_individual, administrateurs: [admin]) }
|
||||||
|
let!(:gi_1_1) { procedure_non_routee.defaut_groupe_instructeur }
|
||||||
|
let!(:gi_1_2) { procedure_non_routee.groupe_instructeurs.create(label: 'groupe instructeur 2') }
|
||||||
|
|
||||||
|
before do
|
||||||
|
patch :update_state,
|
||||||
|
params: {
|
||||||
|
procedure_id: procedure_non_routee.id,
|
||||||
|
groupe_instructeur_id: group.id,
|
||||||
|
closed: closed_value
|
||||||
|
}
|
||||||
|
group.reload
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when we try do disable the default groupe instructeur' do
|
||||||
|
let(:closed_value) { '1' }
|
||||||
|
let(:group) { gi_1_1 }
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(subject).to redirect_to admin_procedure_groupe_instructeur_path(procedure_non_routee, gi_1_1)
|
||||||
|
expect(gi_1_1.closed).to eq(false)
|
||||||
|
expect(flash.alert).to eq('Il est impossible de désactiver le groupe d’instructeurs par défaut.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when we try do disable the second groupe instructeur' do
|
||||||
|
let(:closed_value) { '1' }
|
||||||
|
let(:group) { gi_1_2 }
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(subject).to redirect_to admin_procedure_groupe_instructeur_path(procedure_non_routee, gi_1_2)
|
||||||
|
expect(gi_1_2.closed).to eq(true)
|
||||||
|
expect(flash.notice).to eq('Le groupe groupe instructeur 2 est désactivé.')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#add_instructeur_procedure_non_routee' do
|
describe '#add_instructeur_procedure_non_routee' do
|
||||||
# faire la meme chose sur une procedure non routee
|
# faire la meme chose sur une procedure non routee
|
||||||
let(:procedure_non_routee) { create :procedure }
|
let(:procedure_non_routee) { create :procedure }
|
||||||
|
@ -636,4 +664,26 @@ describe Administrateurs::GroupeInstructeursController, type: :controller do
|
||||||
|
|
||||||
it { expect(procedure.reload.routing_criteria_name).to eq('new name !') }
|
it { expect(procedure.reload.routing_criteria_name).to eq('new name !') }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#create_simple_routing' do
|
||||||
|
let!(:procedure3) do
|
||||||
|
create(:procedure,
|
||||||
|
types_de_champ_public: [
|
||||||
|
{ type: :drop_down_list, libelle: 'Votre ville', options: ['Paris', 'Lyon', 'Marseille'] },
|
||||||
|
{ type: :text, libelle: 'Un champ texte' }
|
||||||
|
],
|
||||||
|
administrateurs: [admin])
|
||||||
|
end
|
||||||
|
|
||||||
|
let!(:drop_down_tdc) { procedure3.draft_revision.types_de_champ.first }
|
||||||
|
|
||||||
|
before { post :create_simple_routing, params: { procedure_id: procedure3.id, create_simple_routing: { stable_id: drop_down_tdc.stable_id } } }
|
||||||
|
|
||||||
|
it do
|
||||||
|
expect(response).to redirect_to(admin_procedure_groupe_instructeurs_path(procedure3))
|
||||||
|
expect(flash.notice).to eq 'Les groupes instructeurs ont été ajoutés'
|
||||||
|
expect(procedure3.groupe_instructeurs.pluck(:label)).to match_array(['Paris', 'Lyon', 'Marseille'])
|
||||||
|
expect(procedure3.reload.defaut_groupe_instructeur.routing_rule).to eq(ds_eq(champ_value(drop_down_tdc.stable_id), constant('Lyon')))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,24 +17,7 @@ describe 'Manage procedure instructeurs', js: true do
|
||||||
scenario 'it works' do
|
scenario 'it works' do
|
||||||
visit admin_procedure_path(procedure)
|
visit admin_procedure_path(procedure)
|
||||||
find('#groupe-instructeurs').click
|
find('#groupe-instructeurs').click
|
||||||
expect(page).to have_css("h1", text: "Gérer les instructeurs et les options d'instruction de « #{procedure.libelle} »")
|
expect(page).to have_css("h1", text: "Gestion des instructeurs")
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context 'as admin not from manager' do
|
|
||||||
let(:manager) { false }
|
|
||||||
|
|
||||||
scenario 'can add instructeur' do
|
|
||||||
visit admin_procedure_groupe_instructeurs_path(procedure)
|
|
||||||
expect {
|
|
||||||
fill_in "instructeur_emails", with: create(:instructeur).email
|
|
||||||
click_on "Affecter"
|
|
||||||
}.to change { procedure.instructeurs.count }.by(1)
|
|
||||||
expect {
|
|
||||||
fill_in "groupe_instructeur_label", with: "Bordeaux"
|
|
||||||
click_on "Ajouter le groupe"
|
|
||||||
}.to change { procedure.groupe_instructeurs.count }.by(1)
|
|
||||||
expect(procedure.reload.routing_enabled).to eq true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
describe 'As an administrateur I can manage procedure routing', js: true do
|
|
||||||
include Logic
|
|
||||||
|
|
||||||
let(:administrateur) { procedure.administrateurs.first }
|
|
||||||
let!(:gi_1) { procedure.defaut_groupe_instructeur }
|
|
||||||
let!(:gi_2) { procedure.groupe_instructeurs.create(label: 'a second group') }
|
|
||||||
let!(:gi_3) { procedure.groupe_instructeurs.create(label: 'a third group') }
|
|
||||||
|
|
||||||
let(:procedure) do
|
|
||||||
create(:procedure).tap do |p|
|
|
||||||
p.draft_revision.add_type_de_champ(
|
|
||||||
type_champ: :drop_down_list,
|
|
||||||
libelle: 'Un champ choix simple',
|
|
||||||
options: { "drop_down_other" => "0", "drop_down_options" => ["", "Premier choix", "Deuxième choix", "Troisième choix"] }
|
|
||||||
)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
let(:drop_down_tdc) { procedure.draft_revision.types_de_champ.first }
|
|
||||||
|
|
||||||
before do
|
|
||||||
Flipper.enable(:routing_rules, procedure)
|
|
||||||
procedure.publish_revision!
|
|
||||||
login_as administrateur.user, scope: :user
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'routes from a drop_down_list' do
|
|
||||||
visit admin_procedure_groupe_instructeurs_path(procedure)
|
|
||||||
|
|
||||||
within('.condition-table tbody tr:nth-child(1)', match: :first) do
|
|
||||||
expect(page).to have_select('targeted_champ', options: ['Sélectionner', 'Un champ choix simple'])
|
|
||||||
within('.target') { select('Un champ choix simple') }
|
|
||||||
within('.value') { select('Premier choix') }
|
|
||||||
end
|
|
||||||
|
|
||||||
expected_routing_rule = ds_eq(champ_value(drop_down_tdc.stable_id), constant('Premier choix'))
|
|
||||||
wait_until { gi_2.reload.routing_rule == expected_routing_rule }
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'displays groupes instructeurs by alphabetic order' do
|
|
||||||
visit admin_procedure_groupe_instructeurs_path(procedure)
|
|
||||||
|
|
||||||
within('.condition-table tbody tr:nth-child(1)', match: :first) do
|
|
||||||
expect(page).to have_content 'second group'
|
|
||||||
expect(page).not_to have_content 'défaut'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,238 +0,0 @@
|
||||||
describe 'The routing', js: true do
|
|
||||||
let(:password) { 'a very complicated password' }
|
|
||||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual, :with_zone) }
|
|
||||||
let(:administrateur) { create(:administrateur, procedures: [procedure]) }
|
|
||||||
let(:scientifique_user) { create(:user, password: password) }
|
|
||||||
let(:litteraire_user) { create(:user, password: password) }
|
|
||||||
|
|
||||||
before do
|
|
||||||
procedure.update(routing_enabled: true)
|
|
||||||
procedure.defaut_groupe_instructeur.instructeurs << administrateur.instructeur
|
|
||||||
end
|
|
||||||
|
|
||||||
scenario 'works' do
|
|
||||||
login_as administrateur.user, scope: :user
|
|
||||||
visit admin_procedure_path(procedure.id)
|
|
||||||
find('#groupe-instructeurs').click
|
|
||||||
|
|
||||||
# add littéraire groupe
|
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'littéraire'
|
|
||||||
click_on 'Ajouter le groupe'
|
|
||||||
expect(page).to have_text('Le groupe d’instructeurs « littéraire » a été créé et le routage a été activé.')
|
|
||||||
|
|
||||||
# add victor to littéraire groupe
|
|
||||||
fill_in 'Emails', with: 'victor@inst.com'
|
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
|
||||||
expect(page).to have_text("L’instructeur victor@inst.com a été affecté")
|
|
||||||
|
|
||||||
victor = User.find_by(email: 'victor@inst.com').instructeur
|
|
||||||
|
|
||||||
# add superwoman to littéraire groupe
|
|
||||||
fill_in 'Emails', with: 'superwoman@inst.com'
|
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
|
||||||
expect(page).to have_text("L’instructeur superwoman@inst.com a été affecté")
|
|
||||||
|
|
||||||
superwoman = User.find_by(email: 'superwoman@inst.com').instructeur
|
|
||||||
|
|
||||||
# rename routing criteria to spécialité
|
|
||||||
click_on 'Groupes d’instructeurs'
|
|
||||||
fill_in 'Libellé de la liste de groupes', with: 'spécialité'
|
|
||||||
click_on 'Renommer'
|
|
||||||
expect(page).to have_text('Le libellé est maintenant « spécialité ».')
|
|
||||||
expect(page).to have_field('Libellé de la liste de groupes', with: 'spécialité')
|
|
||||||
|
|
||||||
# add inactive groupe
|
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'non visible car inactif'
|
|
||||||
click_on 'Ajouter le groupe'
|
|
||||||
check "Groupe inactif"
|
|
||||||
click_on 'Modifier'
|
|
||||||
|
|
||||||
# add scientifique groupe
|
|
||||||
click_on 'Groupes d’instructeurs'
|
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'scientifique'
|
|
||||||
click_on 'Ajouter le groupe'
|
|
||||||
expect(page).to have_text('Le groupe d’instructeurs « scientifique » a été créé.')
|
|
||||||
|
|
||||||
# add marie to scientifique groupe
|
|
||||||
fill_in 'Emails', with: 'marie@inst.com'
|
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
|
||||||
expect(page).to have_text("L’instructeur marie@inst.com a été affecté")
|
|
||||||
|
|
||||||
marie = User.find_by(email: 'marie@inst.com').instructeur
|
|
||||||
|
|
||||||
# add superwoman to scientifique groupe
|
|
||||||
fill_in 'Emails', with: 'superwoman@inst.com'
|
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
|
||||||
expect(page).to have_text("L’instructeur superwoman@inst.com a été affecté")
|
|
||||||
|
|
||||||
# publish
|
|
||||||
publish_procedure(procedure)
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# 2 users fill a dossier in each group
|
|
||||||
user_send_dossier(scientifique_user, 'scientifique')
|
|
||||||
user_send_dossier(litteraire_user, 'littéraire')
|
|
||||||
|
|
||||||
# the litteraires instructeurs only manage the litteraires dossiers
|
|
||||||
register_instructeur_and_log_in(victor.email)
|
|
||||||
click_on procedure.libelle
|
|
||||||
expect(page).to have_text(litteraire_user.email)
|
|
||||||
expect(page).not_to have_text(scientifique_user.email)
|
|
||||||
|
|
||||||
# the search only show litteraires dossiers
|
|
||||||
fill_in 'q', with: scientifique_user.email
|
|
||||||
find('.fr-search-bar .fr-btn').click
|
|
||||||
expect(page).to have_text('0 dossier trouvé')
|
|
||||||
|
|
||||||
fill_in 'q', with: litteraire_user.email
|
|
||||||
find('.fr-search-bar .fr-btn').click
|
|
||||||
expect(page).to have_text('1 dossier trouvé')
|
|
||||||
|
|
||||||
## and the result is clickable
|
|
||||||
click_on litteraire_user.email
|
|
||||||
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
|
|
||||||
|
|
||||||
# follow the dossier
|
|
||||||
click_on 'Suivre le dossier'
|
|
||||||
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# the scientifiques instructeurs only manage the scientifiques dossiers
|
|
||||||
register_instructeur_and_log_in(marie.email)
|
|
||||||
click_on procedure.libelle
|
|
||||||
expect(page).not_to have_text(litteraire_user.email)
|
|
||||||
expect(page).to have_text(scientifique_user.email)
|
|
||||||
|
|
||||||
# follow the dossier
|
|
||||||
click_on scientifique_user.email
|
|
||||||
click_on 'Suivre le dossier'
|
|
||||||
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# litteraire_user change its dossier
|
|
||||||
visit new_user_session_path
|
|
||||||
sign_in_with litteraire_user.email, password
|
|
||||||
|
|
||||||
click_on litteraire_user.dossiers.first.id.to_s
|
|
||||||
click_on 'Modifier mon dossier'
|
|
||||||
|
|
||||||
fill_in litteraire_user.dossiers.first.champs_public.first.libelle, with: 'some value'
|
|
||||||
wait_for_autosave(false)
|
|
||||||
|
|
||||||
click_on 'Déposer les modifications'
|
|
||||||
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# the litteraires instructeurs should have a notification
|
|
||||||
visit new_user_session_path
|
|
||||||
sign_in_with victor.user.email, password
|
|
||||||
|
|
||||||
## on the procedures list
|
|
||||||
expect(page).to have_current_path(instructeur_procedures_path)
|
|
||||||
expect(find('.procedure-stats')).to have_css('span.notifications')
|
|
||||||
|
|
||||||
## on the dossiers list
|
|
||||||
click_on procedure.libelle
|
|
||||||
expect(page).to have_current_path(instructeur_procedure_path(procedure))
|
|
||||||
expect(find('.tabs')).to have_css('span.notifications')
|
|
||||||
|
|
||||||
## on the dossier itself
|
|
||||||
click_on 'suivi'
|
|
||||||
click_on litteraire_user.email
|
|
||||||
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
|
|
||||||
expect(page).to have_text('Annotations privées')
|
|
||||||
expect(find('.tabs')).to have_css('span.notifications')
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# the scientifiques instructeurs should not have a notification
|
|
||||||
visit new_user_session_path
|
|
||||||
sign_in_with marie.user.email, password
|
|
||||||
|
|
||||||
expect(page).to have_current_path(instructeur_procedures_path)
|
|
||||||
expect(find('.procedure-stats')).not_to have_css('span.notifications')
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litterraire dossiers
|
|
||||||
register_instructeur_and_log_in(superwoman.email)
|
|
||||||
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
|
|
||||||
expect(page).to have_text(litteraire_user.email)
|
|
||||||
expect(page).to have_text(scientifique_user.email)
|
|
||||||
|
|
||||||
# follow the dossier
|
|
||||||
click_on scientifique_user.email
|
|
||||||
click_on 'Suivre le dossier'
|
|
||||||
|
|
||||||
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
|
|
||||||
click_on litteraire_user.email
|
|
||||||
click_on 'Suivre le dossier'
|
|
||||||
log_out
|
|
||||||
|
|
||||||
# scientifique_user updates its group
|
|
||||||
user_update_group(scientifique_user, 'littéraire')
|
|
||||||
|
|
||||||
# the instructeurs who belong to scientifique AND litteraire groups should have a notification
|
|
||||||
visit new_user_session_path
|
|
||||||
sign_in_with superwoman.user.email, password
|
|
||||||
|
|
||||||
expect(page).to have_current_path(instructeur_procedures_path)
|
|
||||||
expect(find('.procedure-stats')).to have_css('span.notifications')
|
|
||||||
end
|
|
||||||
|
|
||||||
def publish_procedure(procedure)
|
|
||||||
click_on procedure.libelle
|
|
||||||
find('#publish-procedure-link').click
|
|
||||||
fill_in 'lien_site_web', with: 'http://some.website'
|
|
||||||
click_on 'Publier'
|
|
||||||
|
|
||||||
expect(page).to have_text('Démarche publiée')
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_send_dossier(user, groupe)
|
|
||||||
login_as user, scope: :user
|
|
||||||
visit commencer_path(path: procedure.reload.path)
|
|
||||||
click_on 'Commencer la démarche'
|
|
||||||
|
|
||||||
choose 'Monsieur'
|
|
||||||
fill_in 'individual_nom', with: 'Nom'
|
|
||||||
fill_in 'individual_prenom', with: 'Prenom'
|
|
||||||
click_button('Continuer')
|
|
||||||
|
|
||||||
select(groupe, from: 'dossier_groupe_instructeur_id')
|
|
||||||
wait_for_autosave
|
|
||||||
|
|
||||||
click_on 'Déposer le dossier'
|
|
||||||
expect(page).to have_text('Merci')
|
|
||||||
|
|
||||||
log_out
|
|
||||||
end
|
|
||||||
|
|
||||||
def user_update_group(user, new_group)
|
|
||||||
login_as user, scope: :user
|
|
||||||
visit dossiers_path
|
|
||||||
click_on user.dossiers.first.id.to_s
|
|
||||||
click_on "Modifier mon dossier"
|
|
||||||
expect(page).to have_selector("option", text: "scientifique")
|
|
||||||
expect(page).not_to have_selector("option", text: "Groupe inactif")
|
|
||||||
|
|
||||||
select(new_group, from: 'dossier_groupe_instructeur_id')
|
|
||||||
wait_for_autosave(false)
|
|
||||||
|
|
||||||
expect(page).to have_text(new_group)
|
|
||||||
|
|
||||||
click_on 'Déposer les modifications'
|
|
||||||
|
|
||||||
log_out
|
|
||||||
end
|
|
||||||
|
|
||||||
def register_instructeur_and_log_in(email)
|
|
||||||
confirmation_email = emails_sent_to(email)
|
|
||||||
.find { |m| m.subject == 'Activez votre compte instructeur' }
|
|
||||||
token_params = confirmation_email.body.match(/token=[^"]+/)
|
|
||||||
|
|
||||||
visit "users/activate?#{token_params}"
|
|
||||||
fill_in :user_password, with: password
|
|
||||||
click_button 'Définir le mot de passe'
|
|
||||||
|
|
||||||
expect(page).to have_text('Mot de passe enregistré')
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -23,15 +23,46 @@ describe 'The routing with rules', js: true do
|
||||||
procedure.defaut_groupe_instructeur.instructeurs << administrateur.instructeur
|
procedure.defaut_groupe_instructeur.instructeurs << administrateur.instructeur
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario 'works' do
|
scenario 'Routage à partir d’un champ' do
|
||||||
login_as administrateur.user, scope: :user
|
steps_to_routing_configuration
|
||||||
visit admin_procedure_path(procedure.id)
|
|
||||||
find('#groupe-instructeurs').click
|
|
||||||
|
|
||||||
# add littéraire groupe
|
choose('À partir d’un champ', allow_label_click: true)
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'littéraire'
|
click_on 'Continuer'
|
||||||
click_on 'Ajouter le groupe'
|
|
||||||
expect(page).to have_text('Le groupe d’instructeurs « littéraire » a été créé et le routage a été activé.')
|
expect(page).to have_text('Routage à partir d’un champ')
|
||||||
|
|
||||||
|
choose('Spécialité', allow_label_click: true)
|
||||||
|
click_on 'Créer les groupes'
|
||||||
|
|
||||||
|
expect(page).to have_text('Gestion des groupes')
|
||||||
|
expect(page).to have_text('2 groupes')
|
||||||
|
expect(page).not_to have_text('À configurer')
|
||||||
|
|
||||||
|
click_on 'littéraire'
|
||||||
|
expect(page).to have_select("targeted_champ", selected: "Spécialité")
|
||||||
|
expect(page).to have_select("value", selected: "littéraire")
|
||||||
|
|
||||||
|
click_on '2 groupes'
|
||||||
|
click_on 'scientifique'
|
||||||
|
|
||||||
|
expect(page).to have_select("targeted_champ", selected: "Spécialité")
|
||||||
|
expect(page).to have_select("value", selected: "scientifique")
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario 'Routage personnalisé' do
|
||||||
|
steps_to_routing_configuration
|
||||||
|
|
||||||
|
choose('Avancé', allow_label_click: true)
|
||||||
|
click_on 'Continuer'
|
||||||
|
|
||||||
|
expect(page).to have_text('Gestion des groupes')
|
||||||
|
|
||||||
|
# update defaut groupe
|
||||||
|
click_on 'défaut'
|
||||||
|
expect(page).to have_text('Paramètres principaux')
|
||||||
|
fill_in 'Nom du groupe', with: 'littéraire'
|
||||||
|
click_on 'Renommer'
|
||||||
|
expect(page).to have_text('Le nom est à présent « littéraire ». ')
|
||||||
|
|
||||||
# add victor to littéraire groupe
|
# add victor to littéraire groupe
|
||||||
fill_in 'Emails', with: 'victor@inst.com'
|
fill_in 'Emails', with: 'victor@inst.com'
|
||||||
|
@ -48,18 +79,19 @@ describe 'The routing with rules', js: true do
|
||||||
superwoman = User.find_by(email: 'superwoman@inst.com').instructeur
|
superwoman = User.find_by(email: 'superwoman@inst.com').instructeur
|
||||||
|
|
||||||
# add inactive groupe
|
# add inactive groupe
|
||||||
click_on 'Groupes d’instructeurs'
|
click_on 'Ajout de groupes'
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'non visible car inactif'
|
fill_in 'Nouveau groupe', with: 'non visible car inactif'
|
||||||
click_on 'Ajouter le groupe'
|
click_on 'Ajouter'
|
||||||
check "Groupe inactif"
|
expect(page).to have_text('Le groupe d’instructeurs « non visible car inactif » a été créé. ')
|
||||||
click_on 'Modifier'
|
check("Groupe inactif", allow_label_click: true)
|
||||||
|
|
||||||
# add scientifique groupe
|
|
||||||
click_on 'Groupes d’instructeurs'
|
|
||||||
fill_in 'Ajouter un nom de groupe', with: 'scientifique'
|
|
||||||
click_on 'Ajouter le groupe'
|
|
||||||
expect(page).to have_text('Le groupe d’instructeurs « scientifique » a été créé.')
|
|
||||||
|
|
||||||
|
# # add scientifique groupe
|
||||||
|
click_on '3 groupes'
|
||||||
|
click_on 'défaut bis'
|
||||||
|
fill_in 'Nom du groupe', with: 'scientifique'
|
||||||
|
click_on 'Renommer'
|
||||||
|
expect(page).to have_text('Le nom est à présent « scientifique ». ')
|
||||||
|
#
|
||||||
# add marie to scientifique groupe
|
# add marie to scientifique groupe
|
||||||
fill_in 'Emails', with: 'marie@inst.com'
|
fill_in 'Emails', with: 'marie@inst.com'
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
perform_enqueued_jobs { click_on 'Affecter' }
|
||||||
|
@ -71,24 +103,19 @@ describe 'The routing with rules', js: true do
|
||||||
fill_in 'Emails', with: 'superwoman@inst.com'
|
fill_in 'Emails', with: 'superwoman@inst.com'
|
||||||
perform_enqueued_jobs { click_on 'Affecter' }
|
perform_enqueued_jobs { click_on 'Affecter' }
|
||||||
expect(page).to have_text("L’instructeur superwoman@inst.com a été affecté")
|
expect(page).to have_text("L’instructeur superwoman@inst.com a été affecté")
|
||||||
|
#
|
||||||
# add routing rules
|
# add routing rules
|
||||||
click_on 'Groupes d’instructeurs'
|
within('.target') { select('Spécialité') }
|
||||||
|
within('.value') { select('scientifique') }
|
||||||
|
|
||||||
h = procedure.groupe_instructeurs.index_by(&:label).transform_values(&:id)
|
click_on '3 groupes'
|
||||||
|
|
||||||
within(".gi-#{h['scientifique']}") do
|
click_on 'littéraire'
|
||||||
within('.target') { select('Spécialité') }
|
|
||||||
within('.value') { select('scientifique') }
|
|
||||||
end
|
|
||||||
|
|
||||||
within(".gi-#{h['littéraire']}") do
|
within('.target') { select('Spécialité') }
|
||||||
within('.target') { select('Spécialité') }
|
within('.value') { select('littéraire') }
|
||||||
within('.value') { select('littéraire') }
|
|
||||||
end
|
|
||||||
|
|
||||||
not_defauts = procedure.groupe_instructeurs.filter { |gi| ['littéraire', 'scientifique'].include?(gi.label) }
|
procedure.groupe_instructeurs.where(closed: false).each { |gi| wait_until { gi.reload.routing_rule.present? } }
|
||||||
not_defauts.each { |gi| wait_until { gi.reload.routing_rule.present? } }
|
|
||||||
|
|
||||||
# publish
|
# publish
|
||||||
publish_procedure(procedure)
|
publish_procedure(procedure)
|
||||||
|
@ -179,7 +206,7 @@ describe 'The routing with rules', js: true do
|
||||||
expect(find('.procedure-stats')).not_to have_css('span.notifications')
|
expect(find('.procedure-stats')).not_to have_css('span.notifications')
|
||||||
log_out
|
log_out
|
||||||
|
|
||||||
# the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litterraire dossiers
|
# the instructeurs who belong to scientifique AND litteraire groups manage scientifique and litteraire dossiers
|
||||||
register_instructeur_and_log_in(superwoman.email)
|
register_instructeur_and_log_in(superwoman.email)
|
||||||
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
|
visit instructeur_procedure_path(procedure, params: { statut: 'tous' })
|
||||||
expect(page).to have_text(litteraire_user.email)
|
expect(page).to have_text(litteraire_user.email)
|
||||||
|
@ -263,4 +290,15 @@ describe 'The routing with rules', js: true do
|
||||||
|
|
||||||
expect(page).to have_text('Mot de passe enregistré')
|
expect(page).to have_text('Mot de passe enregistré')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def steps_to_routing_configuration
|
||||||
|
login_as administrateur.user, scope: :user
|
||||||
|
visit admin_procedure_path(procedure.id)
|
||||||
|
find('#groupe-instructeurs').click
|
||||||
|
|
||||||
|
click_on 'Options'
|
||||||
|
expect(page).to have_text('Options concernant l’instruction')
|
||||||
|
click_on 'Configurer le routage'
|
||||||
|
expect(page).to have_text('Choix du type de routage')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue