diff --git a/app/controllers/new_gestionnaire/dossiers_controller.rb b/app/controllers/new_gestionnaire/dossiers_controller.rb index 99ce6f033..69ea7ee99 100644 --- a/app/controllers/new_gestionnaire/dossiers_controller.rb +++ b/app/controllers/new_gestionnaire/dossiers_controller.rb @@ -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 diff --git a/app/views/new_gestionnaire/dossiers/instruction.html.haml b/app/views/new_gestionnaire/dossiers/instruction.html.haml index c07dcbe5c..19955f412 100644 --- a/app/views/new_gestionnaire/dossiers/instruction.html.haml +++ b/app/views/new_gestionnaire/dossiers/instruction.html.haml @@ -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 } diff --git a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb index 084a52ed2..988e8e05a 100644 --- a/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb +++ b/spec/controllers/new_gestionnaire/dossiers_controller_spec.rb @@ -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)) }