NewDesign: can ask a new avis
This commit is contained in:
parent
f03d8ef909
commit
2923d4448b
5 changed files with 38 additions and 0 deletions
|
@ -14,4 +14,8 @@
|
|||
color: $grey;
|
||||
margin-bottom: 2 * $default-padding;
|
||||
}
|
||||
|
||||
input[type=email] {
|
||||
max-width: 500px;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,6 +61,11 @@ module NewGestionnaire
|
|||
render json: { lon: lon, lat: lat, zoom: zoom, dossier_id: params[:dossier_id] }
|
||||
end
|
||||
|
||||
def create_avis
|
||||
Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
||||
redirect_to instruction_dossier_path(dossier.procedure, dossier)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def dossier
|
||||
|
@ -70,5 +75,9 @@ module NewGestionnaire
|
|||
def commentaire_params
|
||||
params.require(:commentaire).permit(:body)
|
||||
end
|
||||
|
||||
def avis_params
|
||||
params.require(:avis).permit(:email, :introduction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,3 +4,9 @@
|
|||
%section
|
||||
%h1 Inviter une personne à donner son avis
|
||||
%p.avis-notice Elle pourra consulter, donner un avis sur le dossier et contribuer au fil de messagerie, mais elle ne pourra le modifier.
|
||||
|
||||
= 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'
|
||||
|
|
|
@ -252,6 +252,7 @@ Rails.application.routes.draw do
|
|||
scope :carte do
|
||||
get 'position'
|
||||
end
|
||||
post 'avis' => 'dossiers#create_avis'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -94,4 +94,22 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it { expect(saved_commentaire.dossier).to eq(dossier) }
|
||||
it { expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier)) }
|
||||
end
|
||||
|
||||
describe "#create_avis" do
|
||||
let(:saved_avis) { dossier.avis.first }
|
||||
|
||||
before do
|
||||
post :create_avis, params: {
|
||||
procedure_id: procedure.id,
|
||||
dossier_id: dossier.id,
|
||||
avis: { email: 'email@a.com', introduction: 'intro' }
|
||||
}
|
||||
end
|
||||
|
||||
it { expect(saved_avis.email).to eq('email@a.com') }
|
||||
it { expect(saved_avis.introduction).to eq('intro') }
|
||||
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)) }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue