Dossier instruction: can ask for a confidentiel avis

This commit is contained in:
Simon Lehericey 2017-09-20 10:42:16 +02:00
parent caaa3169e5
commit 3c3e303a59
3 changed files with 11 additions and 4 deletions

View file

@ -87,7 +87,7 @@ module NewGestionnaire
end
def avis_params
params.require(:avis).permit(:email, :introduction)
params.require(:avis).permit(:email, :introduction, :confidentiel)
end
def champs_private_params

View file

@ -8,8 +8,12 @@
= form_for Avis.new, url: avis_dossier_path(@dossier.procedure, @dossier), html: { class: 'form' } do |f|
= f.email_field :email, placeholder: 'Adresse email', required: true
= f.text_area :introduction, rows: 3, value: 'Bonjour, merci de me donner votre avis sur ce dossier.', required: true
.send-wrapper
= f.submit 'Demander un avis', class: 'button send'
.flex.justify-between.align-baseline
.confidentiel-wrapper
= f.label :confidentiel, 'Cet avis est'
= f.select :confidentiel, [['partagé avec les autres experts', false], ['confidentiel', true]]
.send-wrapper
= f.submit 'Demander un avis', class: 'button send'
= render partial: 'new_gestionnaire/avis/avis_list', locals: { avis: @dossier.avis }

View file

@ -1,6 +1,8 @@
require 'spec_helper'
describe NewGestionnaire::DossiersController, type: :controller do
render_views
let(:gestionnaire) { create(:gestionnaire) }
let(:procedure) { create(:procedure, :published, gestionnaires: [gestionnaire]) }
let(:dossier) { create(:dossier, :replied, procedure: procedure) }
@ -122,12 +124,13 @@ describe NewGestionnaire::DossiersController, type: :controller do
post :create_avis, params: {
procedure_id: procedure.id,
dossier_id: dossier.id,
avis: { email: 'email@a.com', introduction: 'intro' }
avis: { email: 'email@a.com', introduction: 'intro', confidentiel: true }
}
end
it { expect(saved_avis.email).to eq('email@a.com') }
it { expect(saved_avis.introduction).to eq('intro') }
it { expect(saved_avis.confidentiel).to eq(true) }
it { expect(saved_avis.dossier).to eq(dossier) }
it { expect(saved_avis.claimant).to eq(gestionnaire) }
it { expect(response).to redirect_to(instruction_dossier_path(dossier.procedure, dossier)) }