feat(traitements): add depose_at to dossiers

This commit is contained in:
Paul Chavard 2021-11-24 14:27:32 +03:00
parent 1f1dd9fce5
commit d847775c68
4 changed files with 15 additions and 4 deletions

View file

@ -10,6 +10,7 @@
# conservation_extension :interval default(0 seconds)
# declarative_triggered_at :datetime
# deleted_user_email_never_send :string
# depose_at :datetime
# en_construction_at :datetime
# en_construction_close_to_expiration_notice_sent_at :datetime
# en_instruction_at :datetime
@ -776,7 +777,7 @@ class Dossier < ApplicationRecord
def after_passer_en_construction
self.conservation_extension = 0.days
self.en_construction_at = self.traitements
self.depose_at = self.en_construction_at = self.traitements
.passer_en_construction
.processed_at
save!
@ -1095,6 +1096,7 @@ class Dossier < ApplicationRecord
def create_missing_traitemets
if en_construction_at.present? && traitements.en_construction.empty?
self.traitements.passer_en_construction(processed_at: en_construction_at)
self.depose_at ||= en_construction_at
end
if en_instruction_at.present? && traitements.en_instruction.empty?
self.traitements.passer_en_instruction(processed_at: en_instruction_at)

View file

@ -0,0 +1,5 @@
class AddDeposeAtToDossiers < ActiveRecord::Migration[6.1]
def change
add_column :dossiers, :depose_at, :datetime
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_11_19_112046) do
ActiveRecord::Schema.define(version: 2021_11_24_111429) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -323,6 +323,7 @@ ActiveRecord::Schema.define(version: 2021_11_19_112046) do
t.index "to_tsvector('french'::regconfig, search_terms)", name: "index_dossiers_on_search_terms", using: :gin
t.bigint "dossier_transfer_id"
t.datetime "identity_updated_at"
t.datetime "depose_at"
t.index ["archived"], name: "index_dossiers_on_archived"
t.index ["dossier_transfer_id"], name: "index_dossiers_on_dossier_transfer_id"
t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id"

View file

@ -456,6 +456,7 @@ describe Dossier do
it { expect(dossier.state).to eq(Dossier.states.fetch(:en_construction)) }
it { expect(dossier.en_construction_at).to eq(beginning_of_day) }
it { expect(dossier.depose_at).to eq(beginning_of_day) }
it { expect(dossier.traitement.state).to eq(Dossier.states.fetch(:en_construction)) }
it { expect(dossier.traitement.processed_at).to eq(beginning_of_day) }
@ -467,6 +468,7 @@ describe Dossier do
expect(dossier.traitements.size).to eq(3)
expect(dossier.traitements.first.processed_at).to eq(beginning_of_day)
expect(dossier.traitement.processed_at.round).to eq(dossier.en_construction_at.round)
expect(dossier.depose_at).to eq(beginning_of_day)
expect(dossier.en_construction_at).to be > beginning_of_day
end
end
@ -490,8 +492,9 @@ describe Dossier do
dossier.repasser_en_construction!(instructeur)
dossier.passer_en_instruction!(instructeur)
expect(dossier.traitements.size).to eq(3)
expect(dossier.traitements.first.processed_at).to eq(beginning_of_day)
expect(dossier.traitements.size).to eq(4)
expect(dossier.traitements.en_construction.first.processed_at).to eq(dossier.depose_at)
expect(dossier.traitements.en_instruction.first.processed_at).to eq(beginning_of_day)
expect(dossier.traitement.processed_at.round).to eq(dossier.en_instruction_at.round)
expect(dossier.en_instruction_at).to be > beginning_of_day
end