From 274e43c5e6494e004645f6a972ca28fdaea7998a Mon Sep 17 00:00:00 2001 From: Paul Chavard Date: Sat, 5 Oct 2024 22:22:04 +0200 Subject: [PATCH] fix(dossier): projected champs should have updated_at --- app/models/concerns/dossier_champs_concern.rb | 2 +- spec/models/concerns/dossier_champs_concern_spec.rb | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/concerns/dossier_champs_concern.rb b/app/models/concerns/dossier_champs_concern.rb index 5612b2dc9..f6e3f4b96 100644 --- a/app/models/concerns/dossier_champs_concern.rb +++ b/app/models/concerns/dossier_champs_concern.rb @@ -25,7 +25,7 @@ module DossierChampsConcern check_valid_row_id?(type_de_champ, row_id) champ = champs_by_public_id[type_de_champ.public_id(row_id)] if champ.nil? - type_de_champ.build_champ(dossier: self, row_id:) + type_de_champ.build_champ(dossier: self, row_id:, updated_at: depose_at || created_at) else champ end diff --git a/spec/models/concerns/dossier_champs_concern_spec.rb b/spec/models/concerns/dossier_champs_concern_spec.rb index e4177db5c..08106be52 100644 --- a/spec/models/concerns/dossier_champs_concern_spec.rb +++ b/spec/models/concerns/dossier_champs_concern_spec.rb @@ -66,6 +66,7 @@ RSpec.describe DossierChampsConcern do it { expect(subject.new_record?).to be_truthy expect(subject.is_a?(Champs::TextChamp)).to be_truthy + expect(subject.updated_at).not_to be_nil } context "in repetition" do @@ -76,6 +77,7 @@ RSpec.describe DossierChampsConcern do expect(subject.new_record?).to be_truthy expect(subject.is_a?(Champs::TextChamp)).to be_truthy expect(subject.row_id).to eq(row_id) + expect(subject.updated_at).not_to be_nil } context "invalid row_id" do @@ -99,6 +101,7 @@ RSpec.describe DossierChampsConcern do it { expect(subject.new_record?).to be_truthy expect(subject.is_a?(Champs::TextChamp)).to be_truthy + expect(subject.updated_at).not_to be_nil } end end