Skip to content

Commit

Permalink
Unset number_of_terms when induction period ongoing
Browse files Browse the repository at this point in the history
There should never be a number_of_terms present on an ongoing induction
period.
  • Loading branch information
peteryates committed Feb 1, 2025
1 parent f9670ff commit bea0a10
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/appropriate_bodies/importers/induction_period_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ def to_h

# used for comparisons in tests
def to_hash
{ appropriate_body_id:, started_on:, finished_on:, induction_programme: convert_induction_programme, number_of_terms: }
{ appropriate_body_id:, started_on:, finished_on:, induction_programme: convert_induction_programme, number_of_terms: fixed_number_of_terms}
end

def to_record
{ appropriate_body_id:, started_on:, finished_on:, induction_programme: convert_induction_programme, number_of_terms:, teacher_id: }
{ **to_hash, teacher_id: }
end

private

def fixed_number_of_terms
(finished_on.present?) ? number_of_terms : nil
end

def convert_induction_programme
{
"Full Induction Programme" => "fip",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,23 @@
end
end

describe 'number of terms' do
context 'when number_of_terms is present and finished_on is blank' do
let(:sample_csv_data) do
<<~CSV
appropriate_body_id,started_on,finished_on,induction_programme_choice,number_of_terms,trn
025e61e7-ec32-eb11-a813-000d3a228dfc,01/01/2012 00:00:00,,,3,2600071
CSV
end

it 'sets the number_of_terms to nil' do
row_data = subject.periods_as_hashes_by_trn['2600071'].first
expect(row_data.fetch(:started_on)).to eql(Date.new(2012, 1, 1))
expect(row_data.fetch(:number_of_terms)).to be_nil
end
end
end

describe 'rebuilding periods' do
context 'when an ECT has no open induction periods' do
let(:sample_csv_data) do
Expand Down

0 comments on commit bea0a10

Please sign in to comment.