[Fix #2540] Allow an instructeur to send a dossier to several instructeurs
This commit is contained in:
parent
523edac4c5
commit
f8a6765367
7 changed files with 57 additions and 10 deletions
|
@ -5,4 +5,10 @@
|
|||
list-style-type: disc;
|
||||
margin-left: 16px;
|
||||
}
|
||||
|
||||
// scss-lint:disable SelectorFormat
|
||||
.form .select2-container .select2-selection__rendered {
|
||||
padding: 12px;
|
||||
}
|
||||
// scss-lint:enable
|
||||
}
|
||||
|
|
|
@ -37,9 +37,13 @@ module NewGestionnaire
|
|||
@potential_recipients = procedure.gestionnaires.reject { |g| g == current_gestionnaire }
|
||||
end
|
||||
|
||||
def envoyer_a_instructeur
|
||||
recipient = Gestionnaire.find(params[:recipient])
|
||||
GestionnaireMailer.send_dossier(current_gestionnaire, dossier, recipient).deliver_later
|
||||
def send_to_instructeurs
|
||||
recipients = Gestionnaire.find(params[:recipients])
|
||||
|
||||
recipients.each do |recipient|
|
||||
GestionnaireMailer.send_dossier(current_gestionnaire, dossier, recipient).deliver_later
|
||||
end
|
||||
|
||||
flash.notice = "Dossier envoyé"
|
||||
redirect_to(personnes_impliquees_gestionnaire_dossier_path(procedure, dossier))
|
||||
end
|
||||
|
|
|
@ -13,4 +13,11 @@ addEventListener('turbolinks:load', () => {
|
|||
maximumSelectionLength: '5',
|
||||
width: '300px'
|
||||
});
|
||||
|
||||
$('.recipients-form select.select2-limited').select2({
|
||||
language: 'fr',
|
||||
placeholder: 'Sélectionnez des instructeurs',
|
||||
maximumSelectionLength: '30',
|
||||
width: '300px'
|
||||
});
|
||||
});
|
||||
|
|
|
@ -4,7 +4,11 @@
|
|||
%p.tab-paragraph
|
||||
Vous êtes le seul instructeur assigné sur cette démarche
|
||||
- else
|
||||
= form_for dossier, url: envoyer_a_instructeur_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form' } do |f|
|
||||
.flex.justify-start.align-baseline
|
||||
= select_tag(:recipient, options_from_collection_for_select(potential_recipients, :id, :email))
|
||||
= form_for dossier, url: send_to_instructeurs_gestionnaire_dossier_path(dossier.procedure, dossier), method: :post, html: { class: 'form recipients-form' } do |f|
|
||||
.flex.justify-start.align-start
|
||||
= select_tag(:recipients,
|
||||
options_from_collection_for_select(potential_recipients, :id, :email),
|
||||
multiple: true,
|
||||
class: 'select2-limited',
|
||||
placeholder: '')
|
||||
= f.submit "Envoyer", class: "button large send gap-left"
|
||||
|
|
|
@ -322,7 +322,7 @@ Rails.application.routes.draw do
|
|||
post 'passer-en-instruction' => 'dossiers#passer_en_instruction'
|
||||
post 'repasser-en-construction' => 'dossiers#repasser_en_construction'
|
||||
post 'terminer'
|
||||
post 'envoyer-a-instructeur' => 'dossiers#envoyer_a_instructeur'
|
||||
post 'send-to-instructeurs' => 'dossiers#send_to_instructeurs'
|
||||
scope :carte do
|
||||
get 'position'
|
||||
end
|
||||
|
|
|
@ -31,7 +31,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#envoyer_a_instructeur' do
|
||||
describe '#send_to_instructeurs' do
|
||||
let(:recipient) { create(:gestionnaire) }
|
||||
let(:gestionnaires) { [gestionnaire, recipient] }
|
||||
let(:mail) { double("mail") }
|
||||
|
@ -45,9 +45,9 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
.and_return(mail)
|
||||
|
||||
post(
|
||||
:envoyer_a_instructeur,
|
||||
:send_to_instructeurs,
|
||||
params: {
|
||||
recipient: recipient,
|
||||
recipients: [recipient],
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id
|
||||
}
|
||||
|
|
|
@ -134,6 +134,32 @@ feature 'The gestionnaire part' do
|
|||
expect(page).to have_text(gestionnaire2.email)
|
||||
end
|
||||
|
||||
scenario 'A gestionnaire can send a dossier to several instructeurs', js: true do
|
||||
instructeur_2 = FactoryBot.create(:gestionnaire)
|
||||
instructeur_3 = FactoryBot.create(:gestionnaire)
|
||||
procedure.gestionnaires << [instructeur_2, instructeur_3]
|
||||
|
||||
send_dossier = double()
|
||||
expect(GestionnaireMailer).to receive(:send_dossier).and_return(send_dossier).twice
|
||||
expect(send_dossier).to receive(:deliver_later).twice
|
||||
|
||||
log_in(gestionnaire.email, password)
|
||||
|
||||
click_on procedure.libelle
|
||||
click_on dossier.user.email
|
||||
|
||||
click_on 'Personnes impliquées'
|
||||
|
||||
first('.select2-container', minimum: 1).click
|
||||
find('li.select2-results__option[role="treeitem"]', text: instructeur_2.email).click
|
||||
first('.select2-container', minimum: 1).click
|
||||
find('li.select2-results__option[role="treeitem"]', text: instructeur_3.email).click
|
||||
|
||||
click_on 'Envoyer'
|
||||
|
||||
expect(page).to have_text("Dossier envoyé")
|
||||
end
|
||||
|
||||
def log_in(email, password)
|
||||
visit '/'
|
||||
click_on 'Connexion'
|
||||
|
|
Loading…
Reference in a new issue