Merge pull request #10710 from demarches-simplifiees/remove-unused-hidden-at-for-dossiers-ldu
[Tech] Retirer la colonne obsolète 'hidden_at' des dossiers (part 1)
This commit is contained in:
commit
cb902732be
8 changed files with 6 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Dossier < ApplicationRecord
|
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 DossierCloneConcern
|
||||||
include DossierCorrectableConcern
|
include DossierCorrectableConcern
|
||||||
|
|
|
@ -1216,10 +1216,6 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
expect(DeletedDossier.where(dossier_id: dossier.id).count).to eq(0)
|
expect(DeletedDossier.where(dossier_id: dossier.id).count).to eq(0)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'does not discard the dossier' do
|
|
||||||
expect(dossier.reload.hidden_at).to eq(nil)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'fill hidden by reason' do
|
it 'fill hidden by reason' do
|
||||||
expect(dossier.reload.hidden_by_reason).not_to eq(nil)
|
expect(dossier.reload.hidden_by_reason).not_to eq(nil)
|
||||||
expect(dossier.reload.hidden_by_reason).to eq("instructeur_request")
|
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
|
context 'with dossier in batch_operation' do
|
||||||
let(:batch_operation) { create(:batch_operation, operation: :archiver, dossiers: [dossier], instructeur: instructeur) }
|
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 { is_expected.to redirect_to(instructeur_dossier_path(dossier.procedure, dossier)) }
|
||||||
it 'flashes message' do
|
it 'flashes message' do
|
||||||
subject
|
subject
|
||||||
|
|
|
@ -112,10 +112,6 @@ FactoryBot.define do
|
||||||
archived { false }
|
archived { false }
|
||||||
end
|
end
|
||||||
|
|
||||||
trait :discarded do
|
|
||||||
hidden_at { Time.zone.now }
|
|
||||||
end
|
|
||||||
|
|
||||||
trait :hidden_by_expired do
|
trait :hidden_by_expired do
|
||||||
hidden_by_expired_at { 1.day.ago }
|
hidden_by_expired_at { 1.day.ago }
|
||||||
hidden_by_reason { DeletedDossier.reasons.fetch(:expired) }
|
hidden_by_reason { DeletedDossier.reasons.fetch(:expired) }
|
||||||
|
|
|
@ -129,12 +129,8 @@ RSpec.describe DossierMailer, type: :mailer do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '.notify_automatic_deletion_to_user' do
|
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
|
describe 'en_construction' do
|
||||||
# let(:dossier) { create(:dossier, :en_construction) }
|
let(:hidden_dossier) { create(:dossier, :en_construction, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') }
|
||||||
let(:hidden_dossier) { create(:dossier, :en_construction, hidden_at: Time.zone.now, hidden_by_reason: 'expired') }
|
|
||||||
|
|
||||||
subject { described_class.notify_automatic_deletion_to_user([hidden_dossier], hidden_dossier.user.email) }
|
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
|
end
|
||||||
|
|
||||||
describe 'termine' do
|
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) }
|
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
|
end
|
||||||
|
|
||||||
describe '.notify_automatic_deletion_to_administration' do
|
describe '.notify_automatic_deletion_to_administration' do
|
||||||
# let(:dossier) { create(:dossier, :en_construction) }
|
let(:hidden_dossier) { create(:dossier, :accepte, hidden_by_expired_at: Time.zone.now, hidden_by_reason: 'expired') }
|
||||||
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) }
|
|
||||||
|
|
||||||
subject { described_class.notify_automatic_deletion_to_administration([hidden_dossier], hidden_dossier.user.email) }
|
subject { described_class.notify_automatic_deletion_to_administration([hidden_dossier], hidden_dossier.user.email) }
|
||||||
|
|
||||||
|
|
|
@ -62,13 +62,6 @@ describe Champ do
|
||||||
|
|
||||||
describe "associations" do
|
describe "associations" do
|
||||||
it { is_expected.to belong_to(:dossier) }
|
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
|
end
|
||||||
|
|
||||||
describe "normalization" do
|
describe "normalization" do
|
||||||
|
|
|
@ -37,7 +37,6 @@ RSpec.describe DossierCloneConcern do
|
||||||
expect(new_dossier.en_instruction_at).to be_nil
|
expect(new_dossier.en_instruction_at).to be_nil
|
||||||
expect(new_dossier.for_procedure_preview).to be_falsey
|
expect(new_dossier.for_procedure_preview).to be_falsey
|
||||||
expect(new_dossier.groupe_instructeur_updated_at).to be_nil
|
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_administration_at).to be_nil
|
||||||
expect(new_dossier.hidden_by_reason).to be_nil
|
expect(new_dossier.hidden_by_reason).to be_nil
|
||||||
expect(new_dossier.hidden_by_user_at).to be_nil
|
expect(new_dossier.hidden_by_user_at).to be_nil
|
||||||
|
|
|
@ -935,7 +935,6 @@ describe Dossier, type: :model do
|
||||||
|
|
||||||
context 'en_construction' do
|
context 'en_construction' do
|
||||||
it 'hide the dossier but does not discard' 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
|
expect(dossier.hidden_by_user_at).to be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ describe Expired::UsersDeletionService do
|
||||||
|
|
||||||
context 'when dossier termine' do
|
context 'when dossier termine' do
|
||||||
let(:dossier) { create(:dossier, :accepte, user:, created_at: last_signed_in_expired) }
|
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 { subject }.to change { dossier.reload.hidden_by_user_at }.from(nil).to(anything)
|
||||||
expect { user.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
expect { user.reload }.to raise_error(ActiveRecord::RecordNotFound)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue