refactor: include corrections

This commit is contained in:
simon lehericey 2024-11-21 11:36:49 +01:00
parent c415b066b9
commit bb198000fe
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
6 changed files with 20 additions and 85 deletions

View file

@ -10,7 +10,7 @@ RSpec.describe Instructeurs::SVASVRDecisionBadgeComponent, type: :component do
context 'with dossier object' do
subject do
render_inline(described_class.new(projection_or_dossier: dossier, procedure:, with_label:))
render_inline(described_class.new(dossier:, procedure:, with_label:))
end
let(:title) { subject.at_css("span")["title"] }
@ -54,22 +54,4 @@ RSpec.describe Instructeurs::SVASVRDecisionBadgeComponent, type: :component do
it { expect(subject).to have_text("4 j. après correction") }
end
end
context 'with projection object' do
subject do
render_inline(described_class.new(projection_or_dossier: projection, procedure:, with_label:))
end
context 'dossier en instruction' do
let(:projection) { DossierProjectionService::DossierProjection.new(dossier_id: 12, state: :en_instruction, sva_svr_decision_on: Date.new(2023, 9, 5)) }
it { expect(subject).to have_text("dans 4 jours") }
end
context 'dossier without sva decision date' do
let(:projection) { DossierProjectionService::DossierProjection.new(dossier_id: 12, state: :en_instruction) }
it { expect(subject).to have_text("Instruction manuelle") }
end
end
end

View file

@ -249,34 +249,6 @@ describe DossierProjectionService do
it { is_expected.to eq('38') }
end
context 'for dossier corrections table' do
let(:table) { 'dossier_corrections' }
let(:column) { 'resolved_at' }
let(:procedure) { create(:procedure) }
let(:columns) { [Column.new(procedure_id: procedure.id, table:, column:)] } # should somehow be present in column concern
let(:dossier) { create(:dossier, :en_construction, procedure:) }
subject { described_class.project(dossiers_ids, columns)[0] }
context "when dossier has pending correction" do
before { create(:dossier_correction, dossier:) }
it { expect(subject.pending_correction?).to be(true) }
it { expect(subject.resolved_corrections?).to eq(false) }
end
context "when dossier has a resolved correction" do
before { create(:dossier_correction, :resolved, dossier:) }
it { expect(subject.pending_correction?).to eq(false) }
it { expect(subject.resolved_corrections?).to eq(true) }
end
context "when dossier has no correction at all" do
it { expect(subject.pending_correction?).to eq(false) }
it { expect(subject.resolved_corrections?).to eq(false) }
end
end
end
end
end