Merge pull request #659 from sgmap/fix_658
[Fix #658] when dossier linked to avis is hidden, do not crash applic…
This commit is contained in:
commit
47bb6250a3
3 changed files with 13 additions and 1 deletions
|
@ -190,7 +190,7 @@ class StatsController < ApplicationController
|
|||
|
||||
average = Avis.with_answer
|
||||
.where(created_at: min_date..max_date)
|
||||
.average("EXTRACT(EPOCH FROM updated_at - created_at) / 86400")
|
||||
.average("EXTRACT(EPOCH FROM avis.updated_at - avis.created_at) / 86400")
|
||||
|
||||
result = average ? average.to_f.round(2) : 0
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ class Avis < ApplicationRecord
|
|||
before_create :try_to_assign_gestionnaire
|
||||
after_create :notify_gestionnaire
|
||||
|
||||
default_scope { joins(:dossier) }
|
||||
scope :with_answer, -> { where.not(answer: nil) }
|
||||
scope :without_answer, -> { where(answer: nil) }
|
||||
scope :for_dossier, ->(dossier_id) { where(dossier_id: dossier_id) }
|
||||
|
|
|
@ -58,6 +58,17 @@ describe BackofficeController, type: :controller do
|
|||
it { expect(response.body).to include("1 avis rendu") }
|
||||
it { expect(response.body).to include(dossier.procedure.libelle) }
|
||||
end
|
||||
|
||||
context 'when dossier linked to avis is hidden' do
|
||||
before do
|
||||
dossier.update_attributes(hidden_at: Time.now)
|
||||
get :invitations
|
||||
end
|
||||
|
||||
it { expect(response.status).to eq(200) }
|
||||
it { expect(response.body).to include("0 avis à rendre") }
|
||||
it { expect(response.body).to include("0 avis rendu") }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue