Merge pull request #4446 from betagouv/last_defaut_groupe_instructeur
Suppression des derniers defaut_groupe_instructeur illégitimes
This commit is contained in:
commit
0d8405d37e
4 changed files with 59 additions and 11 deletions
|
@ -49,7 +49,7 @@ module Instructeurs
|
||||||
@previous_following_instructeurs_emails = previous_followers.pluck(:email)
|
@previous_following_instructeurs_emails = previous_followers.pluck(:email)
|
||||||
@avis_emails = dossier.avis.includes(:instructeur).map(&:email_to_display)
|
@avis_emails = dossier.avis.includes(:instructeur).map(&:email_to_display)
|
||||||
@invites_emails = dossier.invites.map(&:email)
|
@invites_emails = dossier.invites.map(&:email)
|
||||||
@potential_recipients = procedure.defaut_groupe_instructeur.instructeurs.reject { |g| g == current_instructeur }
|
@potential_recipients = dossier.groupe_instructeur.instructeurs.reject { |g| g == current_instructeur }
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_to_instructeurs
|
def send_to_instructeurs
|
||||||
|
|
|
@ -110,8 +110,10 @@ class Instructeur < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def notifications_for_procedure(procedure, scope)
|
def notifications_for_procedure(procedure, scope)
|
||||||
procedure
|
target_groupes = groupe_instructeurs.where(procedure: procedure)
|
||||||
.defaut_groupe_instructeur.dossiers
|
|
||||||
|
Dossier
|
||||||
|
.where(groupe_instructeur: target_groupes)
|
||||||
.send(scope) # :en_cours or :termine or :not_archived (or any other Dossier scope)
|
.send(scope) # :en_cours or :termine or :not_archived (or any other Dossier scope)
|
||||||
.merge(followed_dossiers)
|
.merge(followed_dossiers)
|
||||||
.with_notifications
|
.with_notifications
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
feature 'The routing' do
|
feature 'The routing' do
|
||||||
let(:procedure) { create(:procedure, :with_service, :for_individual) }
|
let(:password) { 'a very complicated password' }
|
||||||
|
let(:procedure) { create(:procedure, :with_type_de_champ, :with_service, :for_individual) }
|
||||||
let(:administrateur) { create(:administrateur, procedures: [procedure]) }
|
let(:administrateur) { create(:administrateur, procedures: [procedure]) }
|
||||||
let(:scientifique_user) { create(:user) }
|
let(:scientifique_user) { create(:user, password: password) }
|
||||||
let(:litteraire_user) { create(:user) }
|
let(:litteraire_user) { create(:user, password: password) }
|
||||||
|
|
||||||
before { Flipper.enable_actor(:routage, administrateur.user) }
|
before { Flipper.enable_actor(:routage, administrateur.user) }
|
||||||
|
|
||||||
|
@ -67,6 +68,9 @@ feature 'The routing' do
|
||||||
click_on litteraire_user.email
|
click_on litteraire_user.email
|
||||||
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
|
expect(page).to have_current_path(instructeur_dossier_path(procedure, litteraire_user.dossiers.first))
|
||||||
|
|
||||||
|
# follow the dossier
|
||||||
|
click_on 'Suivre le dossier'
|
||||||
|
|
||||||
log_out
|
log_out
|
||||||
|
|
||||||
# the scientifiques instructeurs only manage the scientifiques dossiers
|
# the scientifiques instructeurs only manage the scientifiques dossiers
|
||||||
|
@ -74,9 +78,50 @@ feature 'The routing' do
|
||||||
click_on procedure.libelle
|
click_on procedure.libelle
|
||||||
expect(page).not_to have_text(litteraire_user.email)
|
expect(page).not_to have_text(litteraire_user.email)
|
||||||
expect(page).to have_text(scientifique_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
|
log_out
|
||||||
|
|
||||||
# TODO: notifications tests
|
# litteraire_user change its dossier
|
||||||
|
visit root_path
|
||||||
|
click_on 'Connexion'
|
||||||
|
sign_in_with litteraire_user.email, password
|
||||||
|
|
||||||
|
click_on litteraire_user.dossiers.first.id
|
||||||
|
click_on 'Modifier mon dossier'
|
||||||
|
|
||||||
|
fill_in 'dossier_champs_attributes_0_value', with: 'some value'
|
||||||
|
click_on 'Enregistrer les modifications du dossier'
|
||||||
|
log_out
|
||||||
|
|
||||||
|
# the litteraires instructeurs should have a notification
|
||||||
|
visit root_path
|
||||||
|
click_on 'Connexion'
|
||||||
|
sign_in_with victor.user.email, password
|
||||||
|
|
||||||
|
## on the procedures list
|
||||||
|
visit instructeur_procedures_path
|
||||||
|
expect(page).to have_css("span.notifications")
|
||||||
|
|
||||||
|
## on the dossiers list
|
||||||
|
click_on procedure.libelle
|
||||||
|
expect(page).to have_css("span.notifications")
|
||||||
|
|
||||||
|
## on the dossier it self
|
||||||
|
click_on 'suivi'
|
||||||
|
click_on litteraire_user.email
|
||||||
|
expect(page).to have_css("span.notifications")
|
||||||
|
|
||||||
|
log_out
|
||||||
|
|
||||||
|
# the scientifiques instructeurs should not have a notification
|
||||||
|
login_as marie.user, scope: :user
|
||||||
|
visit instructeur_procedures_path
|
||||||
|
expect(page).not_to have_css("span.notifications")
|
||||||
|
log_out
|
||||||
end
|
end
|
||||||
|
|
||||||
def publish_procedure(procedure)
|
def publish_procedure(procedure)
|
||||||
|
@ -113,7 +158,7 @@ feature 'The routing' do
|
||||||
token_params = confirmation_email.body.match(/token=[^"]+/)
|
token_params = confirmation_email.body.match(/token=[^"]+/)
|
||||||
|
|
||||||
visit "users/activate?#{token_params}"
|
visit "users/activate?#{token_params}"
|
||||||
fill_in :user_password, with: 'démarches-simplifiées-pwd'
|
fill_in :user_password, with: password
|
||||||
|
|
||||||
click_button 'Définir le mot de passe'
|
click_button 'Définir le mot de passe'
|
||||||
|
|
||||||
|
|
|
@ -236,15 +236,16 @@ describe Instructeur, type: :model do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#notifications_for_procedure' do
|
describe '#notifications_for_procedure' do
|
||||||
let!(:dossier) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
let(:procedure) { create(:simple_procedure, :routee, :with_type_de_champ_private) }
|
||||||
|
let!(:dossier) { create(:dossier, :followed, groupe_instructeur: procedure.groupe_instructeurs.last, state: Dossier.states.fetch(:en_construction)) }
|
||||||
let(:instructeur) { dossier.follows.first.instructeur }
|
let(:instructeur) { dossier.follows.first.instructeur }
|
||||||
let(:procedure) { dossier.procedure }
|
let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [procedure.groupe_instructeurs.last]) }
|
||||||
let!(:instructeur_2) { create(:instructeur, groupe_instructeurs: [procedure.defaut_groupe_instructeur]) }
|
|
||||||
|
|
||||||
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
let!(:dossier_on_procedure_2) { create(:dossier, :followed, state: Dossier.states.fetch(:en_construction)) }
|
||||||
let!(:instructeur_on_procedure_2) { dossier_on_procedure_2.follows.first.instructeur }
|
let!(:instructeur_on_procedure_2) { dossier_on_procedure_2.follows.first.instructeur }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
procedure.groupe_instructeurs.last.instructeurs << instructeur
|
||||||
instructeur_2.followed_dossiers << dossier
|
instructeur_2.followed_dossiers << dossier
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue