Skip to content

Commit

Permalink
fix(sva): when there were resolved corrections and a pending correction
Browse files Browse the repository at this point in the history
  • Loading branch information
colinux committed Sep 24, 2024
1 parent cae524b commit b50d42f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/services/sva_svr_decision_date_calculator_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def latest_incomplete_correction_date
end

def latest_correction_date
correction_date dossier.corrections.max_by(&:resolved_at)
correction_date dossier.corrections.max_by { _1.resolved_at || Time.current }

Check warning on line 62 in app/services/sva_svr_decision_date_calculator_service.rb

View check run for this annotation

Codecov / codecov/patch

app/services/sva_svr_decision_date_calculator_service.rb#L62

Added line #L62 was not covered by tests
end

def calculate_correction_delay(start_date)
Expand Down
14 changes: 14 additions & 0 deletions spec/services/sva_svr_decision_date_calculator_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@
it 'calculates the date based on SVA rules from the last resolved date' do
expect(subject).to eq(Date.new(2023, 7, 26))
end

context 'and a pending correction' do
before do
travel_to Time.zone.local(2023, 5, 30, 18) do
dossier.flag_as_pending_correction!(build(:commentaire, dossier:))
end

travel_to Time.zone.local(2023, 6, 5, 8)
end

it 'calculates the date, like if resolution will be today and delay restarted' do
expect(subject).to eq(Date.new(2023, 8, 6))
end
end
end

context 'there is a pending correction' do
Expand Down

0 comments on commit b50d42f

Please sign in to comment.