diff --git a/app/models/dossier.rb b/app/models/dossier.rb index 2ef0ce57f..eee97cee9 100644 --- a/app/models/dossier.rb +++ b/app/models/dossier.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Dossier < ApplicationRecord - self.ignored_columns += [:re_instructed_at, :search_terms, :private_search_terms] + self.ignored_columns += [:re_instructed_at, :search_terms, :private_search_terms, :hidden_at] include DossierCloneConcern include DossierCorrectableConcern diff --git a/spec/controllers/instructeurs/dossiers_controller_spec.rb b/spec/controllers/instructeurs/dossiers_controller_spec.rb index 6dc6e84ea..c9227d2ed 100644 --- a/spec/controllers/instructeurs/dossiers_controller_spec.rb +++ b/spec/controllers/instructeurs/dossiers_controller_spec.rb @@ -1216,10 +1216,6 @@ describe Instructeurs::DossiersController, type: :controller do expect(DeletedDossier.where(dossier_id: dossier.id).count).to eq(0) end - it 'does not discard the dossier' do - expect(dossier.reload.hidden_at).to eq(nil) - end - it 'fill hidden by reason' do expect(dossier.reload.hidden_by_reason).not_to eq(nil) expect(dossier.reload.hidden_by_reason).to eq("instructeur_request") @@ -1242,7 +1238,7 @@ describe Instructeurs::DossiersController, type: :controller do context 'with dossier in batch_operation' do let(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier], instructeur: instructeur) } - it { expect { subject }.not_to change { dossier.reload.hidden_at } } + it { expect { subject }.not_to change { dossier.reload.hidden_by_administration_at } } it { is_expected.to redirect_to(instructeur_dossier_path(dossier.procedure, dossier)) } it 'flashes message' do subject diff --git a/spec/factories/dossier.rb b/spec/factories/dossier.rb index 62920f45e..20e88820c 100644 --- a/spec/factories/dossier.rb +++ b/spec/factories/dossier.rb @@ -112,10 +112,6 @@ FactoryBot.define do archived { false } end - trait :discarded do - hidden_at { Time.zone.now } - end - trait :hidden_by_expired do hidden_by_expired_at { 1.day.ago } hidden_by_reason { DeletedDossier.reasons.fetch(:expired) } diff --git a/spec/mailers/dossier_mailer_spec.rb b/spec/mailers/dossier_mailer_spec.rb index 217f231f7..57d66f1d0 100644 --- a/spec/mailers/dossier_mailer_spec.rb +++ b/spec/mailers/dossier_mailer_spec.rb @@ -129,12 +129,8 @@ RSpec.describe DossierMailer, type: :mailer do end describe '.notify_automatic_deletion_to_user' do - # let(:deleted_dossier) { create(:deleted_dossier, dossier: dossier, reason: :expired) } - # let(:hidden_dossier) { build(:dossier, :en_construction, hidden_at: Time.zone.now, hidden_by_reason: 'expired') } - describe 'en_construction' do - # let(:dossier) { create(:dossier, :en_construction) } - let(:hidden_dossier) { create(:dossier, :en_construction, hidden_at: Time.zone.now, hidden_by_reason: 'expired') } + let(:hidden_dossier) { create(:dossier, :en_construction, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') } subject { described_class.notify_automatic_deletion_to_user([hidden_dossier], hidden_dossier.user.email) } @@ -147,7 +143,7 @@ RSpec.describe DossierMailer, type: :mailer do end describe 'termine' do - let(:hidden_dossier) { create(:dossier, :accepte, hidden_at: Time.zone.now, hidden_by_reason: 'expired') } + let(:hidden_dossier) { create(:dossier, :accepte, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') } subject { described_class.notify_automatic_deletion_to_user([hidden_dossier], hidden_dossier.user.email) } @@ -161,9 +157,7 @@ RSpec.describe DossierMailer, type: :mailer do end describe '.notify_automatic_deletion_to_administration' do - # let(:dossier) { create(:dossier, :en_construction) } - let(:hidden_dossier) { create(:dossier, :accepte, hidden_at: Time.zone.now, hidden_by_reason: 'expired') } - # let(:deleted_dossier) { create(:deleted_dossier, dossier: dossier, reason: :expired) } + let(:hidden_dossier) { create(:dossier, :accepte, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') } subject { described_class.notify_automatic_deletion_to_administration([hidden_dossier], hidden_dossier.user.email) } diff --git a/spec/models/champ_spec.rb b/spec/models/champ_spec.rb index 9e586fbf0..4ec2d0798 100644 --- a/spec/models/champ_spec.rb +++ b/spec/models/champ_spec.rb @@ -62,13 +62,6 @@ describe Champ do describe "associations" do it { is_expected.to belong_to(:dossier) } - - context 'when the parent dossier is discarded' do - let(:discarded_dossier) { create(:dossier, :discarded) } - subject(:champ) { discarded_dossier.champs_public.first } - - it { expect(champ.reload.dossier).to eq discarded_dossier } - end end describe "normalization" do diff --git a/spec/models/concerns/dossier_clone_concern_spec.rb b/spec/models/concerns/dossier_clone_concern_spec.rb index 440d87efe..7594cc6fe 100644 --- a/spec/models/concerns/dossier_clone_concern_spec.rb +++ b/spec/models/concerns/dossier_clone_concern_spec.rb @@ -37,7 +37,6 @@ RSpec.describe DossierCloneConcern do expect(new_dossier.en_instruction_at).to be_nil expect(new_dossier.for_procedure_preview).to be_falsey expect(new_dossier.groupe_instructeur_updated_at).to be_nil - expect(new_dossier.hidden_at).to be_nil expect(new_dossier.hidden_by_administration_at).to be_nil expect(new_dossier.hidden_by_reason).to be_nil expect(new_dossier.hidden_by_user_at).to be_nil diff --git a/spec/models/dossier_spec.rb b/spec/models/dossier_spec.rb index 03509f895..7796f48c5 100644 --- a/spec/models/dossier_spec.rb +++ b/spec/models/dossier_spec.rb @@ -935,7 +935,6 @@ describe Dossier, type: :model do context 'en_construction' do it 'hide the dossier but does not discard' do - expect(dossier.hidden_at).to be_nil expect(dossier.hidden_by_user_at).to be_present end diff --git a/spec/services/expired/expired_users_deletion_service_spec.rb b/spec/services/expired/expired_users_deletion_service_spec.rb index 875e5c7c2..1aa3831f4 100644 --- a/spec/services/expired/expired_users_deletion_service_spec.rb +++ b/spec/services/expired/expired_users_deletion_service_spec.rb @@ -74,7 +74,7 @@ describe Expired::UsersDeletionService do context 'when dossier termine' do let(:dossier) { create(:dossier, :accepte, user:, created_at: last_signed_in_expired) } - it 'marks dossier as hidden_at due to user_removal and remove user' do + it 'marks dossier as hidden by user due to user_removal and remove user' do expect { subject }.to change { dossier.reload.hidden_by_user_at }.from(nil).to(anything) expect { user.reload }.to raise_error(ActiveRecord::RecordNotFound) end