Merge pull request #3321 from betagouv/dev

2019-01-23-01
This commit is contained in:
Pierre de La Morinerie 2019-01-23 11:31:19 +01:00 committed by GitHub
commit ac392aa28d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 75 additions and 30 deletions

View file

@ -34,7 +34,7 @@ $procedure-context-breakpoint: $two-columns-breakpoint;
}
.procedure-description {
font-size: 14px;
font-size: 16px;
p {
margin-bottom: 2 * $default-spacer;

View file

@ -13,6 +13,10 @@ module NewGestionnaire
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
end
def apercu_attestation
send_data(dossier.build_attestation.pdf.read, filename: 'apercu_attestation.pdf', disposition: 'inline', type: 'application/pdf')
end
def show
@demande_seen_at = current_gestionnaire.follows.find_by(dossier: dossier)&.demande_seen_at
end

View file

@ -60,11 +60,11 @@ class SupportController < ApplicationController
end
def create_commentaire
params = {
attributes = {
file: params[:file],
body: "[#{params[:subject]}]<br><br>#{params[:text]}"
}
commentaire = CommentaireService.build_with_email(email, dossier, params)
commentaire = CommentaireService.build_with_email(email, dossier, attributes)
commentaire.save!
end

View file

@ -29,5 +29,7 @@
- else
= text_area :dossier, :motivation, class: 'motivation-text-area', placeholder: placeholder, required: true
.text-right
- if title == 'Accepter' && dossier.procedure.attestation_template&.activated?
= link_to "Voir l'attestation", apercu_attestation_gestionnaire_dossier_path(dossier.procedure, dossier), target: '_blank', class: 'button', title: "Voir l'attestation qui sera envoyée au demandeur"
%span.button{ onclick: 'DS.motivationCancel();' } Annuler
= button_tag 'Valider la décision', name: :process_action, value: process_action, class: 'button primary', title: title, data: { confirm: confirm }

View file

@ -316,6 +316,7 @@ Rails.application.routes.draw do
resources :dossiers, only: [:show], param: :dossier_id do
member do
get 'attestation'
get 'apercu_attestation'
get 'messagerie'
get 'annotations-privees' => 'dossiers#annotations_privees'
get 'avis'

View file

@ -7,6 +7,7 @@ describe SupportController, type: :controller do
before do
sign_in user
end
let(:user) { create(:user) }
it 'should not have email field' do
@ -51,55 +52,67 @@ describe SupportController, type: :controller do
end
describe "send form" do
it 'should create conversation' do
expect(subject).not_to receive(:create_commentaire)
allow(subject).to receive(:create_conversation).and_return(true)
subject do
post :create, params: { subject: 'bonjour', text: 'un message' }
end
post :create, params: {
subject: 'bonjour',
text: 'un message'
}
it 'creates a conversation on HelpScout' do
expect_any_instance_of(Helpscout::FormAdapter).to receive(:send_form).and_return(true)
expect { subject }.to change(Commentaire, :count).by(0)
expect(flash[:notice]).to match('Votre message a été envoyé.')
expect(response).to redirect_to root_path(formulaire_contact_general_submitted: true)
end
context "with dossier" do
let(:user) { dossier.user }
context 'when a drafted dossier is mentionned' do
let(:dossier) { create(:dossier) }
let(:user) { dossier.user }
it 'should create conversation' do
expect(subject).not_to receive(:create_commentaire)
allow(subject).to receive(:create_conversation).and_return(true)
subject do
post :create, params: {
dossier_id: dossier.id,
type: Helpscout::FormAdapter::TYPE_INSTRUCTION,
subject: 'bonjour',
text: 'un message'
}
end
it 'creates a conversation on HelpScout' do
expect_any_instance_of(Helpscout::FormAdapter).to receive(:send_form).and_return(true)
expect { subject }.to change(Commentaire, :count).by(0)
expect(flash[:notice]).to match('Votre message a été envoyé.')
expect(response).to redirect_to root_path(formulaire_contact_general_submitted: true)
end
end
context "en_construction" do
let(:dossier) { create(:dossier, :en_construction) }
context 'when a submitted dossier is mentionned' do
let(:dossier) { create(:dossier, :en_construction) }
let(:user) { dossier.user }
it 'should create commentaire' do
allow(subject).to receive(:create_commentaire).and_return(true)
expect(subject).not_to receive(:create_conversation)
subject do
post :create, params: {
dossier_id: dossier.id,
type: Helpscout::FormAdapter::TYPE_INSTRUCTION,
subject: 'bonjour',
text: 'un message'
}
end
post :create, params: {
dossier_id: dossier.id,
type: Helpscout::FormAdapter::TYPE_INSTRUCTION,
subject: 'bonjour',
text: 'un message'
}
it 'posts the message to the dossier messagerie' do
expect_any_instance_of(Helpscout::FormAdapter).not_to receive(:send_form)
expect(flash[:notice]).to match('Votre message a été envoyé sur la messagerie de votre dossier.')
expect(response).to redirect_to messagerie_dossier_path(dossier)
end
expect { subject }.to change(Commentaire, :count).by(1)
expect(Commentaire.last.email).to eq(user.email)
expect(Commentaire.last.dossier).to eq(dossier)
expect(Commentaire.last.body).to include('[bonjour]')
expect(Commentaire.last.body).to include('un message')
expect(flash[:notice]).to match('Votre message a été envoyé sur la messagerie de votre dossier.')
expect(response).to redirect_to messagerie_dossier_path(dossier)
end
end
end

View file

@ -0,0 +1,25 @@
describe 'new_gestionnaire/dossiers/state_button_motivation.html.haml', type: :view do
let(:dossier) { create(:dossier, :en_instruction) }
subject! do
render(
'new_gestionnaire/dossiers/state_button_motivation.html.haml',
dossier: dossier,
popup_title: 'Accepter le dossier',
placeholder: 'Expliquez au demandeur pourquoi ce dossier est accepté (facultatif)',
popup_class: 'accept',
process_action: 'accepter',
title: 'Accepter',
confirm: "Confirmez-vous l'acceptation ce dossier ?"
)
end
context 'with an attestation preview' do
let(:dossier) { create :dossier, :accepte, :with_attestation }
it { expect(rendered).to have_text("Voir l'attestation") }
end
context 'without an attestation preview' do
it { expect(rendered).not_to have_text("Voir l'attestation") }
end
end