feat(correction): make pending corrections blocking by feature flag only
This commit is contained in:
parent
c0b444d747
commit
1a56fe620e
10 changed files with 50 additions and 26 deletions
|
@ -568,7 +568,7 @@ class Dossier < ApplicationRecord
|
|||
end
|
||||
|
||||
def can_passer_en_instruction?
|
||||
return false if pending_correction?
|
||||
return false if procedure.feature_enabled?(:blocking_pending_correction) && pending_correction?
|
||||
|
||||
true
|
||||
end
|
||||
|
@ -579,7 +579,7 @@ class Dossier < ApplicationRecord
|
|||
|
||||
return false if !can_passer_en_instruction?
|
||||
return true if declarative_triggered_at.nil? && procedure.declarative_en_instruction?
|
||||
return true if procedure.sva_svr_enabled? && sva_svr_decision_triggered_at.nil?
|
||||
return true if procedure.sva_svr_enabled? && sva_svr_decision_triggered_at.nil? && !pending_correction?
|
||||
|
||||
false
|
||||
end
|
||||
|
@ -932,6 +932,8 @@ class Dossier < ApplicationRecord
|
|||
.processed_at
|
||||
save!
|
||||
|
||||
resolve_pending_correction!
|
||||
|
||||
MailTemplatePresenterService.create_commentaire_for_state(self, Dossier.states.fetch(:en_instruction))
|
||||
if !disable_notification
|
||||
NotificationMailer.send_en_instruction_notification(self).deliver_later
|
||||
|
|
7
app/models/procedure_flipper_actor.rb
Normal file
7
app/models/procedure_flipper_actor.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
# Use this when we want to check feature flags on a procedure whithout loading the all procedure
|
||||
class ProcedureFlipperActor < Struct.new(:procedure_id) do
|
||||
def flipper_id
|
||||
"Procedure;#{procedure_id}"
|
||||
end
|
||||
end
|
||||
end
|
|
@ -9,6 +9,7 @@
|
|||
close_to_expiration: dossier.close_to_expiration?,
|
||||
hidden_by_administration: dossier.hidden_by_administration?,
|
||||
has_pending_correction: dossier.pending_correction?,
|
||||
has_blocking_pending_correction: dossier.procedure.feature_enabled?(:blocking_pending_correction) && dossier.pending_correction?,
|
||||
turbo: true,
|
||||
with_menu: true }
|
||||
|
||||
|
|
|
@ -45,10 +45,10 @@
|
|||
- if Dossier.states[:en_construction] == state
|
||||
%li{ 'data-turbo': turbo ? 'true' : 'false' }
|
||||
= button_to passer_en_instruction_instructeur_dossier_path(procedure_id, dossier_id), method: :post, class: 'fr-btn fr-icon-edit-line',
|
||||
disabled: has_pending_correction, "aria-describedby" => has_pending_correction ? "tooltip-passer-en-instruction" : nil do
|
||||
disabled: has_blocking_pending_correction, "aria-describedby" => has_blocking_pending_correction ? "tooltip-passer-en-instruction" : nil do
|
||||
= t('views.instructeurs.dossiers.passer_en_instruction')
|
||||
|
||||
- if has_pending_correction
|
||||
- if has_blocking_pending_correction
|
||||
%span#tooltip-passer-en-instruction.fr-tooltip.fr-placement{ role: :tooltip, "aria-hidden" => "true" }
|
||||
= t('views.instructeurs.dossiers.passer_en_instruction_blocked_by_pending_correction')
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@
|
|||
close_to_expiration: @statut == 'expirant',
|
||||
hidden_by_administration: @statut == 'supprimes_recemment',
|
||||
sva_svr: @procedure.sva_svr_enabled?,
|
||||
has_pending_correction: p.pending_correction?,
|
||||
has_blocking_pending_correction: @procedure.feature_enabled?(:blocking_pending_correction) && p.pending_correction?,
|
||||
turbo: false,
|
||||
with_menu: false }
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@
|
|||
close_to_expiration: nil,
|
||||
hidden_by_administration: nil,
|
||||
sva_svr: p.sva_svr_decision_on.present?,
|
||||
has_pending_correction: p.pending_correction?,
|
||||
has_blocking_pending_correction: p.pending_correction? && Flipper.enabled?(:blocking_pending_correction, ProcedureFlipperActor.new(procedure_id)),
|
||||
turbo: false,
|
||||
with_menu: false }
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ features = [
|
|||
:procedure_routage_api,
|
||||
:groupe_instructeur_api_hack,
|
||||
:cojo_type_de_champ,
|
||||
:sva
|
||||
:sva,
|
||||
:blocking_pending_correction
|
||||
]
|
||||
|
||||
def database_exists?
|
||||
|
|
|
@ -31,18 +31,6 @@ RSpec.describe ProcessStalledDeclarativeDossierJob, type: :job do
|
|||
|
||||
it { expect(subject.state).to eq('en_construction') }
|
||||
end
|
||||
|
||||
context 'with pending correction' do
|
||||
let!(:correction) { create(:dossier_correction, dossier:) }
|
||||
|
||||
it { expect(subject.state).to eq('en_construction') }
|
||||
end
|
||||
|
||||
context 'with resolved correction' do
|
||||
let!(:correction) { create(:dossier_correction, :resolved, dossier:) }
|
||||
|
||||
it { expect(subject.state).to eq('en_instruction') }
|
||||
end
|
||||
end
|
||||
|
||||
context 'dossier already en_instruction' do
|
||||
|
|
|
@ -1148,6 +1148,7 @@ describe Dossier, type: :model do
|
|||
let(:last_operation) { dossier.dossier_operation_logs.last }
|
||||
let(:operation_serialized) { last_operation.data }
|
||||
let(:instructeur) { create(:instructeur) }
|
||||
let!(:correction) { create(:dossier_correction, dossier:) } # correction has a commentaire
|
||||
|
||||
subject(:passer_en_instruction) { dossier.passer_en_instruction!(instructeur: instructeur) }
|
||||
|
||||
|
@ -1166,6 +1167,13 @@ describe Dossier, type: :model do
|
|||
|
||||
it { expect { passer_en_instruction }.to change { dossier.commentaires.count }.by(1) }
|
||||
|
||||
it "resolve pending correction" do
|
||||
passer_en_instruction
|
||||
|
||||
expect(dossier.pending_correction?).to be_falsey
|
||||
expect(correction.reload.resolved_at).to be_present
|
||||
end
|
||||
|
||||
it 'creates a commentaire in the messagerie with expected wording' do
|
||||
passer_en_instruction
|
||||
|
||||
|
@ -1253,13 +1261,24 @@ describe Dossier, type: :model do
|
|||
context 'when there is a pending correction' do
|
||||
before { create(:dossier_correction, dossier:) }
|
||||
|
||||
it { expect(dossier.can_passer_en_instruction?).to be_falsey }
|
||||
it { expect(dossier.can_passer_en_instruction?).to be_truthy }
|
||||
end
|
||||
|
||||
context 'when there is a resolved correction' do
|
||||
before { create(:dossier_correction, :resolved, dossier:) }
|
||||
context 'when there is a pending correction with procedure blocking_pending_correction feature' do
|
||||
let(:resolved_at) { nil }
|
||||
|
||||
it { expect(dossier.can_passer_en_instruction?).to be_truthy }
|
||||
before do
|
||||
Flipper.enable(:blocking_pending_correction, dossier.procedure)
|
||||
create(:dossier_correction, dossier:, resolved_at: resolved_at)
|
||||
end
|
||||
|
||||
it { expect(dossier.can_passer_en_instruction?).to be_falsey }
|
||||
|
||||
context 'when there is a resolved correction' do
|
||||
let(:resolved_at) { Time.current }
|
||||
|
||||
it { expect(dossier.can_passer_en_instruction?).to be_truthy }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -68,9 +68,15 @@ describe 'instructeurs/dossiers/show', type: :view do
|
|||
context 'with pending correction' do
|
||||
before { create(:dossier_correction, dossier:) }
|
||||
|
||||
it 'disable the instruction button' do
|
||||
expect(subject).to have_button('Passer en instruction', disabled: true)
|
||||
expect(subject).to have_content('Le passage en instruction est impossible')
|
||||
it { expect(subject).to have_button('Passer en instruction', disabled: false) }
|
||||
|
||||
context 'with procedure blocking pending correction' do
|
||||
before { Flipper.enable(:blocking_pending_correction, dossier.procedure) }
|
||||
|
||||
it 'disable the instruction button' do
|
||||
expect(subject).to have_button('Passer en instruction', disabled: true)
|
||||
expect(subject).to have_content('Le passage en instruction est impossible')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue