Merge branch 'dev'
This commit is contained in:
commit
cbbaf867ee
12 changed files with 52 additions and 53 deletions
|
@ -1,5 +1,7 @@
|
|||
module NewGestionnaire
|
||||
class DossiersController < ProceduresController
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
||||
def attestation
|
||||
send_data(dossier.attestation.pdf.read, filename: 'attestation.pdf', type: 'application/pdf')
|
||||
end
|
||||
|
@ -51,12 +53,20 @@ module NewGestionnaire
|
|||
end
|
||||
|
||||
def create_commentaire
|
||||
@commentaire = Commentaire.new(commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier))
|
||||
commentaire_hash = commentaire_params.merge(email: current_gestionnaire.email, dossier: dossier)
|
||||
|
||||
# avoid simple_format replacing '' by '<p></p>'
|
||||
# and thus skipping the not empty constraint on commentaire's body
|
||||
if commentaire_hash[:body].present?
|
||||
commentaire_hash[:body] = simple_format(commentaire_hash[:body])
|
||||
end
|
||||
|
||||
@commentaire = Commentaire.new(commentaire_hash)
|
||||
|
||||
if @commentaire.save
|
||||
current_gestionnaire.follow(dossier)
|
||||
flash.notice = "Message envoyé"
|
||||
redirect_to messagerie_dossier_path(dossier.procedure, dossier)
|
||||
redirect_to messagerie_dossier_path(procedure, dossier)
|
||||
else
|
||||
flash.alert = @commentaire.errors.full_messages
|
||||
render :messagerie
|
||||
|
@ -81,13 +91,13 @@ module NewGestionnaire
|
|||
|
||||
def create_avis
|
||||
Avis.create(avis_params.merge(claimant: current_gestionnaire, dossier: dossier))
|
||||
redirect_to avis_dossier_path(dossier.procedure, dossier)
|
||||
redirect_to avis_dossier_path(procedure, dossier)
|
||||
end
|
||||
|
||||
def update_annotations
|
||||
dossier = current_gestionnaire.dossiers.includes(champs_private: :type_de_champ).find(params[:dossier_id])
|
||||
dossier.update_attributes(champs_private_params)
|
||||
redirect_to annotations_privees_dossier_path(dossier.procedure, dossier)
|
||||
redirect_to annotations_privees_dossier_path(procedure, dossier)
|
||||
end
|
||||
|
||||
def print
|
||||
|
|
|
@ -3,15 +3,16 @@
|
|||
= commentaire.header
|
||||
.content
|
||||
= sanitize(commentaire.body)
|
||||
- if commentaire.file.present?
|
||||
.file
|
||||
= link_to commentaire.file_url, class: 'link', target: '_blank' do
|
||||
%span.fa.fa-file
|
||||
%div
|
||||
= commentaire.file_identifier
|
||||
- elsif file = commentaire.piece_justificative
|
||||
|
||||
- if file = commentaire.piece_justificative
|
||||
.file
|
||||
= link_to file.content_url, class: 'link', target: '_blank' do
|
||||
%span.fa.fa-file
|
||||
%div
|
||||
= file.original_filename
|
||||
- elsif commentaire.file.present?
|
||||
.file
|
||||
= link_to commentaire.file_url, class: 'link', target: '_blank' do
|
||||
%span.fa.fa-file
|
||||
%div
|
||||
= commentaire.file_identifier
|
||||
|
|
|
@ -7,15 +7,15 @@
|
|||
- if ![current_gestionnaire.email, @dossier.user.email, 'contact@tps.apientreprise.fr'].include?(commentaire.email)
|
||||
%span.guest Invité
|
||||
%span.date= I18n.l(commentaire.created_at.localtime, format: '%H:%M le %d/%m/%Y')
|
||||
%p.rich-text= sanitize(commentaire.body)
|
||||
.rich-text= sanitize(commentaire.body)
|
||||
|
||||
- if commentaire.file.present?
|
||||
.attachment-link
|
||||
= link_to commentaire.file_url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
.icon.attachment
|
||||
= commentaire.file_identifier
|
||||
- elsif commentaire.piece_justificative
|
||||
- if commentaire.piece_justificative
|
||||
.attachment-link
|
||||
= link_to commentaire.piece_justificative.content_url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
.icon.attachment
|
||||
= commentaire.piece_justificative.original_filename
|
||||
- elsif commentaire.file.present?
|
||||
.attachment-link
|
||||
= link_to commentaire.file_url, class: "button", target: "_blank", title: "Télécharger" do
|
||||
.icon.attachment
|
||||
= commentaire.file_identifier
|
||||
|
|
|
@ -12,6 +12,8 @@ describe Admin::AttestationTemplatesController, type: :controller do
|
|||
Timecop.freeze(Time.now)
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
describe 'POST #preview' do
|
||||
let(:upload_params) { { title: 't', body: 'b', footer: 'f' } }
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
|
||||
describe "#create_commentaire" do
|
||||
let(:saved_commentaire) { dossier.commentaires.first }
|
||||
let(:body) { "body" }
|
||||
let(:body) { "avant\napres" }
|
||||
let(:file) { nil }
|
||||
let(:scan_result) { true }
|
||||
|
||||
|
@ -133,7 +133,7 @@ describe NewGestionnaire::DossiersController, type: :controller do
|
|||
it do
|
||||
subject
|
||||
|
||||
expect(saved_commentaire.body).to eq('body')
|
||||
expect(saved_commentaire.body).to eq("<p>avant\n<br />apres</p>")
|
||||
expect(saved_commentaire.email).to eq(gestionnaire.email)
|
||||
expect(saved_commentaire.dossier).to eq(dossier)
|
||||
expect(response).to redirect_to(messagerie_dossier_path(dossier.procedure, dossier))
|
||||
|
|
|
@ -59,6 +59,8 @@ describe StatsController, type: :controller do
|
|||
FactoryGirl.create(:procedure, :created_at => 15.days.ago, :updated_at => 1.hour.ago)
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
|
||||
let (:association) { Procedure.all }
|
||||
|
||||
context "while a super admin is logged in" do
|
||||
|
@ -85,8 +87,6 @@ describe StatsController, type: :controller do
|
|||
})
|
||||
}
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
end
|
||||
|
||||
describe "#procedures_count_per_administrateur" do
|
||||
|
@ -230,9 +230,8 @@ describe StatsController, type: :controller do
|
|||
let!(:avis_with_dossier) { create(:avis) }
|
||||
let!(:dossier2) { create(:dossier) }
|
||||
|
||||
before do
|
||||
Timecop.freeze(Time.now)
|
||||
end
|
||||
before { Timecop.freeze(Time.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:avis_usage) }
|
||||
|
||||
|
@ -271,9 +270,8 @@ describe StatsController, type: :controller do
|
|||
|
||||
subject { StatsController.new.send(:avis_answer_percentages) }
|
||||
|
||||
before do
|
||||
Timecop.freeze(Time.now)
|
||||
end
|
||||
before { Timecop.freeze(Time.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
it { is_expected.to match [[3.week.ago.to_i, 0], [2.week.ago.to_i, 0], [1.week.ago.to_i, 66.67]] }
|
||||
end
|
||||
|
@ -283,9 +281,8 @@ describe StatsController, type: :controller do
|
|||
let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||
let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
|
||||
|
||||
before do
|
||||
Timecop.freeze(Time.now)
|
||||
end
|
||||
before { Timecop.freeze(Time.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:motivation_usage_dossier) }
|
||||
|
||||
|
@ -298,9 +295,8 @@ describe StatsController, type: :controller do
|
|||
let!(:dossier2) { create(:dossier, processed_at: 1.week.ago) }
|
||||
let!(:dossier3) { create(:dossier, processed_at: 1.week.ago) }
|
||||
|
||||
before do
|
||||
Timecop.freeze(Time.now)
|
||||
end
|
||||
before { Timecop.freeze(Time.now) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { StatsController.new.send(:motivation_usage_procedure) }
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ RSpec.describe AutoReceiveDossiersForProcedureJob, type: :job do
|
|||
let(:date) { Time.utc(2017, 9, 1, 10, 5, 0) }
|
||||
|
||||
before { Timecop.freeze(date) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject { AutoReceiveDossiersForProcedureJob.new.perform(procedure_id) }
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ describe AttestationTemplate, type: :model do
|
|||
after do
|
||||
@logo.close
|
||||
@signature.close
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
let(:view_args) do
|
||||
|
|
|
@ -892,6 +892,7 @@ describe Dossier do
|
|||
let(:modif_date) { DateTime.parse('01/01/2100') }
|
||||
|
||||
before { Timecop.freeze(modif_date) }
|
||||
after { Timecop.return }
|
||||
|
||||
subject do
|
||||
dossier.reload
|
||||
|
@ -941,8 +942,6 @@ describe Dossier do
|
|||
|
||||
it { is_expected.to eq(modif_date) }
|
||||
end
|
||||
|
||||
after { Timecop.return }
|
||||
end
|
||||
|
||||
describe '#owner_name' do
|
||||
|
|
|
@ -314,10 +314,7 @@ describe Gestionnaire, type: :model do
|
|||
let(:friday) { DateTime.new(2017, 5, 12) }
|
||||
let(:monday) { DateTime.now.beginning_of_week }
|
||||
|
||||
before :each do
|
||||
Timecop.freeze(friday)
|
||||
end
|
||||
|
||||
before { Timecop.freeze(friday) }
|
||||
after { Timecop.return }
|
||||
|
||||
context 'when no procedure published was active last week' do
|
||||
|
@ -563,10 +560,9 @@ describe Gestionnaire, type: :model do
|
|||
Timecop.freeze(freeze_date)
|
||||
gestionnaire.mark_tab_as_seen(dossier, :demande)
|
||||
end
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(follow.demande_seen_at).to eq(freeze_date) }
|
||||
|
||||
after { Timecop.return }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,9 +5,8 @@ describe ProcedureOverview, type: :model do
|
|||
let(:friday) { DateTime.new(2017, 5, 12) } # vendredi 12 mai 2017, de la semaine du 8 mai
|
||||
let(:monday) { DateTime.new(2017, 5, 8) }
|
||||
|
||||
before :each do
|
||||
Timecop.freeze(friday)
|
||||
end
|
||||
before { Timecop.freeze(friday) }
|
||||
after { Timecop.return }
|
||||
|
||||
let(:procedure_overview) { ProcedureOverview.new(procedure, monday) }
|
||||
|
||||
|
|
|
@ -237,16 +237,13 @@ describe Procedure do
|
|||
Timecop.freeze(now)
|
||||
procedure.publish!("example-path")
|
||||
end
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(procedure.archived_at).to eq(nil) }
|
||||
it { expect(procedure.published_at).to eq(now) }
|
||||
it { expect(ProcedurePath.find_by_path("example-path")).to be }
|
||||
it { expect(ProcedurePath.find_by_path("example-path").procedure).to eq(procedure) }
|
||||
it { expect(ProcedurePath.find_by_path("example-path").administrateur).to eq(procedure.administrateur) }
|
||||
|
||||
after do
|
||||
Timecop.return
|
||||
end
|
||||
end
|
||||
|
||||
describe "#brouillon?" do
|
||||
|
@ -300,13 +297,10 @@ describe Procedure do
|
|||
procedure.archive
|
||||
procedure.reload
|
||||
end
|
||||
after { Timecop.return }
|
||||
|
||||
it { expect(procedure.archivee?).to be_truthy }
|
||||
it { expect(procedure.archived_at).to eq(now) }
|
||||
|
||||
after do
|
||||
Timecop.return
|
||||
end
|
||||
end
|
||||
|
||||
describe 'total_dossier' do
|
||||
|
|
Loading…
Add table
Reference in a new issue