Add Dossier#text_summary
This commit is contained in:
parent
c0fd56ea8e
commit
f5c5ad532d
2 changed files with 42 additions and 0 deletions
|
@ -278,6 +278,28 @@ class Dossier < ActiveRecord::Base
|
||||||
!(procedure.archived && draft?)
|
!(procedure.archived && draft?)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def text_summary
|
||||||
|
if brouillon?
|
||||||
|
parts = [
|
||||||
|
"Dossier en brouillon répondant à la démarche ",
|
||||||
|
procedure.libelle,
|
||||||
|
", gérée par l'organisme ",
|
||||||
|
procedure.organisation
|
||||||
|
]
|
||||||
|
else
|
||||||
|
parts = [
|
||||||
|
"Dossier déposé le ",
|
||||||
|
initiated_at.strftime("%d/%m/%Y"),
|
||||||
|
", sur la démarche ",
|
||||||
|
procedure.libelle,
|
||||||
|
", gérée par l'organisme ",
|
||||||
|
procedure.organisation
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
parts.join
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_state_dates
|
def update_state_dates
|
||||||
|
|
|
@ -809,6 +809,26 @@ describe Dossier do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#text_summary" do
|
||||||
|
let(:procedure) { create(:procedure, libelle: "Démarche", organisation: "Organisation") }
|
||||||
|
|
||||||
|
context 'when the dossier has been initiated' do
|
||||||
|
let(:dossier) { create :dossier, procedure: procedure, state: 'initiated', initiated_at: "31/12/2010".to_date }
|
||||||
|
|
||||||
|
subject { dossier.text_summary }
|
||||||
|
|
||||||
|
it { is_expected.to eq("Dossier déposé le 31/12/2010, sur la démarche Démarche, gérée par l'organisme Organisation") }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when the dossier has not been initiated' do
|
||||||
|
let(:dossier) { create :dossier, procedure: procedure, state: 'draft' }
|
||||||
|
|
||||||
|
subject { dossier.text_summary }
|
||||||
|
|
||||||
|
it { is_expected.to eq("Dossier en brouillon répondant à la démarche Démarche, gérée par l'organisme Organisation") }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#update_state_dates' do
|
describe '#update_state_dates' do
|
||||||
let(:state) { 'draft' }
|
let(:state) { 'draft' }
|
||||||
let(:dossier) { create(:dossier, state: state) }
|
let(:dossier) { create(:dossier, state: state) }
|
||||||
|
|
Loading…
Reference in a new issue