fix(spec/lint/review): lint and fix spec of previous commits, also fix based on tchak feedback
This commit is contained in:
parent
d87f8b57cc
commit
1bb868714c
9 changed files with 36 additions and 33 deletions
|
@ -15,13 +15,9 @@ module Instructeurs
|
||||||
dossiers = current_instructeur.dossiers.joins(:groupe_instructeur)
|
dossiers = current_instructeur.dossiers.joins(:groupe_instructeur)
|
||||||
@dossiers_count_per_procedure = dossiers.all_state.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
@dossiers_count_per_procedure = dossiers.all_state.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
||||||
@dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
@dossiers_a_suivre_count_per_procedure = dossiers.without_followers.en_cours.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
||||||
@dossiers_archived_count_per_procedure = dossiers.archived.group('groupe_instructeurs.procedure_id').count #why not reorder(nil)
|
@dossiers_archived_count_per_procedure = dossiers.archived.group('groupe_instructeurs.procedure_id').count # why not reorder(nil)
|
||||||
@dossiers_termines_count_per_procedure = dossiers.termine.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
@dossiers_termines_count_per_procedure = dossiers.termine.group('groupe_instructeurs.procedure_id').reorder(nil).count
|
||||||
<<<<<<< HEAD
|
|
||||||
@dossiers_expirant_count_per_procedure = dossiers.termine_close_to_expiration.group('groupe_instructeurs.procedure_id').count #why not reorder(nil)
|
|
||||||
=======
|
|
||||||
@dossiers_expirant_count_per_procedure = dossiers.termine_or_en_construction_close_to_expiration.group('groupe_instructeurs.procedure_id').count # why not reorder(nil)
|
@dossiers_expirant_count_per_procedure = dossiers.termine_or_en_construction_close_to_expiration.group('groupe_instructeurs.procedure_id').count # why not reorder(nil)
|
||||||
>>>>>>> 2722cf295 (fixup! feat(instructeurs/procedures#show): add dossier experiant in procedure#show)
|
|
||||||
groupe_ids = current_instructeur.groupe_instructeurs.pluck(:id)
|
groupe_ids = current_instructeur.groupe_instructeurs.pluck(:id)
|
||||||
|
|
||||||
@followed_dossiers_count_per_procedure = current_instructeur
|
@followed_dossiers_count_per_procedure = current_instructeur
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
# last_commentaire_updated_at :datetime
|
# last_commentaire_updated_at :datetime
|
||||||
# motivation :text
|
# motivation :text
|
||||||
# private_search_terms :text
|
# private_search_terms :text
|
||||||
# process_expired :boolean default(FALSE)
|
|
||||||
# processed_at :datetime
|
# processed_at :datetime
|
||||||
# search_terms :text
|
# search_terms :text
|
||||||
# state :string
|
# state :string
|
||||||
|
@ -297,7 +296,7 @@ class Dossier < ApplicationRecord
|
||||||
end
|
end
|
||||||
scope :interval_termine_close_to_expiration, -> do
|
scope :interval_termine_close_to_expiration, -> do
|
||||||
state_termine
|
state_termine
|
||||||
.where(procedures: { procedure_expires_when_termine_enabled: true})
|
.where(procedures: { procedure_expires_when_termine_enabled: true })
|
||||||
.where("dossiers.processed_at + dossiers.conservation_extension + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
.where("dossiers.processed_at + dossiers.conservation_extension + (duree_conservation_dossiers_dans_ds * INTERVAL '1 month') - INTERVAL :expires_in < :now", { now: Time.zone.now, expires_in: INTERVAL_BEFORE_EXPIRATION })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,6 @@ class ExpiredDossiersDeletionService
|
||||||
deleted_dossier_ids << dossier.id
|
deleted_dossier_ids << dossier.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
user_notifications.each do |(email, dossier_ids)|
|
user_notifications.each do |(email, dossier_ids)|
|
||||||
dossier_ids = dossier_ids.intersection(deleted_dossier_ids)
|
dossier_ids = dossier_ids.intersection(deleted_dossier_ids)
|
||||||
if dossier_ids.present?
|
if dossier_ids.present?
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
class AddExpirantsToProcedurePresentations < ActiveRecord::Migration[6.1]
|
class AddExpirantsToProcedurePresentations < ActiveRecord::Migration[6.1]
|
||||||
def up
|
def up
|
||||||
ProcedurePresentation.update_all(%Q(filters = filters || '{"expirant": []}'))
|
ProcedurePresentation.update_all(%Q(filters = filters || '{"expirant": []}'))
|
||||||
change_column_default :procedure_presentations, :filters, {"tous"=>[], "suivis"=>[], "traites"=>[], "a-suivre"=>[], "archives"=>[], "expirant": []}
|
change_column_default :procedure_presentations, :filters, { "tous" => [], "suivis" => [], "traites" => [], "a-suivre" => [], "archives" => [], "expirant": [] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
change_column_default :procedure_presentations, :filters, {"tous"=>[], "suivis"=>[], "traites"=>[], "a-suivre"=>[], "archives"=>[]}
|
change_column_default :procedure_presentations, :filters, { "tous" => [], "suivis" => [], "traites" => [], "a-suivre" => [], "archives" => [] }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,14 +2,14 @@ namespace :after_party do
|
||||||
desc 'Deployment task: move_traitement_process_expired_to_procedure'
|
desc 'Deployment task: move_traitement_process_expired_to_procedure'
|
||||||
|
|
||||||
task move_traitement_process_expired_to_procedure: :environment do
|
task move_traitement_process_expired_to_procedure: :environment do
|
||||||
procedures = Procedure.joins(dossiers: :traitements).where(dossiers: {traitements: {process_expired: true, process_expired_migrated: false}})
|
procedures = Procedure.joins(dossiers: :traitements).where(dossiers: { traitements: { process_expired: true, process_expired_migrated: false } })
|
||||||
progress = ProgressReport.new(procedures.count)
|
progress = ProgressReport.new(procedures.count)
|
||||||
|
|
||||||
procedures.group(:id).find_each do |procedure|
|
procedures.group(:id).find_each do |procedure|
|
||||||
ActiveRecord::Base.transaction do
|
ActiveRecord::Base.transaction do
|
||||||
puts "update traitements from dossier_ids: #{procedure.dossiers.ids}"
|
puts "update traitements from dossier_ids: #{procedure.dossiers.ids}"
|
||||||
Traitement.where(id: procedure.dossiers.ids).update_all(process_expired_migrated: true)
|
Traitement.where(id: procedure.dossiers.ids).update_all(process_expired_migrated: true)
|
||||||
Procedure.update(procedure_expires_when_termine_enabled: true)
|
procedure.update(procedure_expires_when_termine_enabled: true)
|
||||||
progress.inc
|
progress.inc
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -135,10 +135,12 @@ FactoryBot.define do
|
||||||
if processed_at.present?
|
if processed_at.present?
|
||||||
dossier.en_construction_at ||= processed_at - 2.minutes
|
dossier.en_construction_at ||= processed_at - 2.minutes
|
||||||
dossier.en_instruction_at ||= processed_at - 1.minute
|
dossier.en_instruction_at ||= processed_at - 1.minute
|
||||||
|
dossier.processed_at = processed_at
|
||||||
dossier.traitements.accepter(motivation: evaluator.motivation, processed_at: processed_at)
|
dossier.traitements.accepter(motivation: evaluator.motivation, processed_at: processed_at)
|
||||||
else
|
else
|
||||||
dossier.en_construction_at ||= dossier.created_at + 1.minute
|
dossier.en_construction_at ||= dossier.created_at + 1.minute
|
||||||
dossier.en_instruction_at ||= dossier.en_construction_at + 1.minute
|
dossier.en_instruction_at ||= dossier.en_construction_at + 1.minute
|
||||||
|
dossier.processed_at = dossier.en_instruction_at + 1.minute
|
||||||
dossier.traitements.accepter(motivation: evaluator.motivation, processed_at: dossier.en_instruction_at + 1.minute)
|
dossier.traitements.accepter(motivation: evaluator.motivation, processed_at: dossier.en_instruction_at + 1.minute)
|
||||||
end
|
end
|
||||||
dossier.save!
|
dossier.save!
|
||||||
|
|
|
@ -747,7 +747,6 @@ describe Instructeur, type: :model do
|
||||||
context 'with an expirants dossier' do
|
context 'with an expirants dossier' do
|
||||||
let!(:expiring_dossier_termine) { create(:dossier, :accepte, procedure: procedure, processed_at: 175.days.ago) }
|
let!(:expiring_dossier_termine) { create(:dossier, :accepte, procedure: procedure, processed_at: 175.days.ago) }
|
||||||
let!(:expiring_dossier_en_construction) { create(:dossier, :en_construction, en_construction_at: 175.days.ago, procedure: procedure) }
|
let!(:expiring_dossier_en_construction) { create(:dossier, :en_construction, en_construction_at: 175.days.ago, procedure: procedure) }
|
||||||
|
|
||||||
before { subject }
|
before { subject }
|
||||||
|
|
||||||
it { expect(subject['a_suivre']).to eq(1) }
|
it { expect(subject['a_suivre']).to eq(1) }
|
||||||
|
|
|
@ -2,8 +2,9 @@ describe ExpiredDossiersDeletionService do
|
||||||
let(:warning_period) { 1.month + 5.days }
|
let(:warning_period) { 1.month + 5.days }
|
||||||
let(:conservation_par_defaut) { 3.months }
|
let(:conservation_par_defaut) { 3.months }
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:procedure) { create(:procedure, :published) }
|
let(:procedure_opts) { {} }
|
||||||
let(:procedure_2) { create(:procedure, :published) }
|
let(:procedure) { create(:procedure, :published, procedure_opts) }
|
||||||
|
let(:procedure_2) { create(:procedure, :published, procedure_opts) }
|
||||||
let(:reference_date) { Date.parse("March 8") }
|
let(:reference_date) { Date.parse("March 8") }
|
||||||
|
|
||||||
describe '#process_expired_dossiers_brouillon' do
|
describe '#process_expired_dossiers_brouillon' do
|
||||||
|
@ -273,19 +274,18 @@ describe ExpiredDossiersDeletionService do
|
||||||
describe '#send_termine_expiration_notices' do
|
describe '#send_termine_expiration_notices' do
|
||||||
before { Timecop.freeze(reference_date) }
|
before { Timecop.freeze(reference_date) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
let(:procedure_opts) do
|
||||||
before do
|
{
|
||||||
Flipper.enable(:procedure_process_expired_dossiers_termine, procedure)
|
procedure_expires_when_termine_enabled: true
|
||||||
Flipper.enable(:procedure_process_expired_dossiers_termine, procedure_2)
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
allow(DossierMailer).to receive(:notify_near_deletion_to_user).and_call_original
|
allow(DossierMailer).to receive(:notify_near_deletion_to_user).and_call_original
|
||||||
allow(DossierMailer).to receive(:notify_near_deletion_to_administration).and_call_original
|
allow(DossierMailer).to receive(:notify_near_deletion_to_administration).and_call_original
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a single dossier' do
|
context 'with a single dossier' do
|
||||||
let!(:dossier) { create(:dossier, :accepte, :followed, procedure: procedure, processed_at: processed_at) }
|
let!(:dossier) { create(:dossier, :followed, state: :accepte, procedure: procedure, processed_at: processed_at) }
|
||||||
|
|
||||||
before { ExpiredDossiersDeletionService.send_termine_expiration_notices }
|
before { ExpiredDossiersDeletionService.send_termine_expiration_notices }
|
||||||
|
|
||||||
|
@ -311,8 +311,8 @@ describe ExpiredDossiersDeletionService do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with 2 dossiers to notice' do
|
context 'with 2 dossiers to notice' do
|
||||||
let!(:dossier_1) { create(:dossier, :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
let!(:dossier_1) { create(:dossier, state: :accepte, procedure: procedure, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||||
let!(:dossier_2) { create(:dossier, :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
let!(:dossier_2) { create(:dossier, state: :accepte, procedure: procedure_2, user: user, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||||
|
|
||||||
let!(:instructeur) { create(:instructeur) }
|
let!(:instructeur) { create(:instructeur) }
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ describe ExpiredDossiersDeletionService do
|
||||||
|
|
||||||
context 'when an instructeur is also administrateur' do
|
context 'when an instructeur is also administrateur' do
|
||||||
let!(:administrateur) { procedure.administrateurs.first }
|
let!(:administrateur) { procedure.administrateurs.first }
|
||||||
let!(:dossier) { create(:dossier, :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
let!(:dossier) { create(:dossier, state: :accepte, procedure: procedure, processed_at: (conservation_par_defaut - 2.weeks + 1.day).ago) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
administrateur.instructeur.followed_dossiers << dossier
|
administrateur.instructeur.followed_dossiers << dossier
|
||||||
|
@ -348,9 +348,10 @@ describe ExpiredDossiersDeletionService do
|
||||||
before { Timecop.freeze(reference_date) }
|
before { Timecop.freeze(reference_date) }
|
||||||
after { Timecop.return }
|
after { Timecop.return }
|
||||||
|
|
||||||
before do
|
let(:procedure_opts) do
|
||||||
Flipper.enable(:procedure_process_expired_dossiers_termine, procedure)
|
{
|
||||||
Flipper.enable(:procedure_process_expired_dossiers_termine, procedure_2)
|
procedure_expires_when_termine_enabled: true
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -359,7 +360,7 @@ describe ExpiredDossiersDeletionService do
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with a single dossier' do
|
context 'with a single dossier' do
|
||||||
let!(:dossier) { create(:dossier, :accepte, :followed, procedure: procedure, termine_close_to_expiration_notice_sent_at: notice_sent_at) }
|
let!(:dossier) { create(:dossier, :followed, :accepte, procedure: procedure, termine_close_to_expiration_notice_sent_at: notice_sent_at) }
|
||||||
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
let(:deleted_dossier) { DeletedDossier.find_by(dossier_id: dossier.id) }
|
||||||
|
|
||||||
before { ExpiredDossiersDeletionService.delete_expired_termine_and_notify }
|
before { ExpiredDossiersDeletionService.delete_expired_termine_and_notify }
|
||||||
|
|
|
@ -1,6 +1,13 @@
|
||||||
describe 'shared/dossiers/expiration_banner.html.haml', type: :view do
|
describe 'shared/dossiers/expiration_banner.html.haml', type: :view do
|
||||||
include DossierHelper
|
include DossierHelper
|
||||||
let(:dossier) { build(:dossier, state, attributes.merge(id: 1, state: state)) }
|
|
||||||
|
let(:dossier) do
|
||||||
|
create(:dossier, state, attributes.merge(
|
||||||
|
id: 1,
|
||||||
|
state: state,
|
||||||
|
procedure: create(:procedure, procedure_expires_when_termine_enabled: expiration_enabled)
|
||||||
|
))
|
||||||
|
end
|
||||||
let(:i18n_key_state) { state }
|
let(:i18n_key_state) { state }
|
||||||
subject do
|
subject do
|
||||||
render('shared/dossiers/expiration_banner.html.haml',
|
render('shared/dossiers/expiration_banner.html.haml',
|
||||||
|
@ -8,8 +15,8 @@ describe 'shared/dossiers/expiration_banner.html.haml', type: :view do
|
||||||
current_user: build(:user))
|
current_user: build(:user))
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with procedure having procedure_process_expired_dossiers_termine not enabled' do
|
context 'with procedure having procedure_expires_when_termine_enabled not enabled' do
|
||||||
before { allow(dossier.procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(false) }
|
let(:expiration_enabled) { false }
|
||||||
let(:attributes) { { processed_at: 6.months.ago } }
|
let(:attributes) { { processed_at: 6.months.ago } }
|
||||||
let(:state) { :accepte }
|
let(:state) { :accepte }
|
||||||
|
|
||||||
|
@ -18,8 +25,8 @@ describe 'shared/dossiers/expiration_banner.html.haml', type: :view do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with procedure having procedure_process_expired_dossiers_termine enabled' do
|
context 'with procedure having procedure_expires_when_termine_enabled enabled' do
|
||||||
before { allow(dossier.procedure).to receive(:feature_enabled?).with(:procedure_process_expired_dossiers_termine).and_return(true) }
|
let(:expiration_enabled) { true }
|
||||||
|
|
||||||
context 'with dossier.brouillon?' do
|
context 'with dossier.brouillon?' do
|
||||||
let(:attributes) { { created_at: 6.months.ago } }
|
let(:attributes) { { created_at: 6.months.ago } }
|
||||||
|
|
Loading…
Reference in a new issue