Skip to content

Commit

Permalink
fix sva_svr specs
Browse files Browse the repository at this point in the history
  • Loading branch information
maatinito committed Oct 10, 2023
1 parent c6da862 commit 4ba3ced
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
40 changes: 20 additions & 20 deletions spec/services/sva_svr_decision_date_calculator_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
include ActiveSupport::Testing::TimeHelpers

let(:procedure) { create(:procedure, sva_svr: config) }
let(:dossier) { create(:dossier, :en_instruction, procedure:, depose_at: DateTime.new(2023, 5, 15, 12)) }
let(:dossier) { create(:dossier, :en_instruction, procedure:, depose_at: Time.zone.local(2023, 5, 15, 12)) }

describe '#decision_date' do
subject { described_class.new(dossier, procedure).decision_date }
Expand Down Expand Up @@ -38,8 +38,8 @@

context 'when a dossier is corrected and resolved' do
let!(:correction) do
created_at = DateTime.new(2023, 5, 20, 15)
resolved_at = DateTime.new(2023, 5, 25, 12)
created_at = Time.zone.local(2023, 5, 20, 15)
resolved_at = Time.zone.local(2023, 5, 25, 12)
create(:dossier_correction, dossier:, created_at:, resolved_at:)
end

Expand All @@ -49,8 +49,8 @@

context 'when there are multiple corrections' do
let!(:correction2) do
created_at = DateTime.new(2023, 5, 30, 18)
resolved_at = DateTime.new(2023, 6, 3, 8)
created_at = Time.zone.local(2023, 5, 30, 18)
resolved_at = Time.zone.local(2023, 6, 3, 8)
create(:dossier_correction, dossier:, created_at:, resolved_at:)
end

Expand All @@ -61,11 +61,11 @@

context 'there is a pending correction kind = correct' do
before do
travel_to DateTime.new(2023, 5, 30, 18) do
travel_to Time.zone.local(2023, 5, 30, 18) do
dossier.flag_as_pending_correction!(build(:commentaire, dossier:))
end

travel_to DateTime.new(2023, 6, 5, 8) # 6 days elapsed, restart 1 day after resolved
travel_to Time.zone.local(2023, 6, 5, 8) # 6 days elapsed, restart 1 day after resolved
end

it 'calculates the date, like if resolution will be today' do
Expand All @@ -75,11 +75,11 @@

context 'there is a pending correction kind = incomplete' do
before do
travel_to DateTime.new(2023, 5, 30, 18) do
travel_to Time.zone.local(2023, 5, 30, 18) do
dossier.flag_as_pending_correction!(build(:commentaire, dossier:), :incomplete)
end

travel_to DateTime.new(2023, 6, 5, 8) # 6 days elapsed
travel_to Time.zone.local(2023, 6, 5, 8) # 6 days elapsed
end

it 'calculates the date, like if resolution will be today' do
Expand All @@ -89,8 +89,8 @@

context 'when correction was for an incomplete dossier' do
let!(:correction) do
created_at = DateTime.new(2023, 5, 20, 15)
resolved_at = DateTime.new(2023, 5, 25, 12)
created_at = Time.zone.local(2023, 5, 20, 15)
resolved_at = Time.zone.local(2023, 5, 25, 12)
create(:dossier_correction, :incomplete, dossier:, created_at:, resolved_at:)
end

Expand All @@ -100,8 +100,8 @@

context 'when there are multiple corrections' do
let!(:correction2) do
created_at = DateTime.new(2023, 5, 30, 18)
resolved_at = DateTime.new(2023, 6, 3, 8)
created_at = Time.zone.local(2023, 5, 30, 18)
resolved_at = Time.zone.local(2023, 6, 3, 8)
create(:dossier_correction, dossier:, created_at:, resolved_at:)
end

Expand All @@ -124,12 +124,12 @@

context 'there are multiple resolved correction' do
before do
created_at = DateTime.new(2023, 5, 16, 15)
resolved_at = DateTime.new(2023, 5, 17, 12)
created_at = Time.zone.local(2023, 5, 16, 15)
resolved_at = Time.zone.local(2023, 5, 17, 12)
create(:dossier_correction, :incomplete, dossier:, created_at:, resolved_at:)

created_at = DateTime.new(2023, 5, 20, 15)
resolved_at = DateTime.new(2023, 5, 25, 12)
created_at = Time.zone.local(2023, 5, 20, 15)
resolved_at = Time.zone.local(2023, 5, 25, 12)
create(:dossier_correction, dossier:, created_at:, resolved_at:)
end

Expand All @@ -140,11 +140,11 @@

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

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

it 'calculates the date, like if resolution will be today and delay restarted' do
Expand All @@ -156,7 +156,7 @@

describe '#decision_date_from_today' do
let(:config) { { decision: :sva, period: 2, unit: :months, resume: :continue } }
before { travel_to DateTime.new(2023, 4, 15, 12) }
before { travel_to Time.zone.local(2023, 4, 15, 12) }

subject { described_class.decision_date_from_today(procedure) }

Expand Down
2 changes: 1 addition & 1 deletion spec/views/shared/_procedure_description.html.haml_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
end

context 'when the procedure is sva' do
before { travel_to DateTime.new(2023, 1, 1) }
before { travel_to Time.zone.local(2023, 1, 1) }
let(:procedure) { create(:procedure, :published, :sva) }

it 'shows an explanation text' do
Expand Down

0 comments on commit 4ba3ced

Please sign in to comment.