diff --git a/app/models/bulk_search.rb b/app/models/bulk_search.rb index 66998cfd..8fc0397c 100644 --- a/app/models/bulk_search.rb +++ b/app/models/bulk_search.rb @@ -73,7 +73,7 @@ def find_all(queries) def response @response ||= begin - queries = csv.map { |row| { trn: row["TRN"], dateOfBirth: row["Date of birth"] } }.compact + queries = csv.map { |row| { trn: row["TRN"], dateOfBirth: Date.parse(row["Date of birth"]) } }.compact find_all(queries) end end diff --git a/spec/models/bulk_search_spec.rb b/spec/models/bulk_search_spec.rb index cd306152..486f0179 100644 --- a/spec/models/bulk_search_spec.rb +++ b/spec/models/bulk_search_spec.rb @@ -74,6 +74,20 @@ expect(call.third).to eq(["trn" => '3001403', "date_of_birth" => Date.parse('01/01/1990')]) end + it 'parses the date of birth correctly in the queries' do + expect_any_instance_of(QualificationsApi::Client).to receive(:bulk_teachers) do |_, queries:| + expect(queries).to include( + hash_including( + trn: '3001403', + dateOfBirth: Date.parse('01/01/1990') + ) + ) + { "results" => [], "total" => 0 } + end + + call + end + context 'when the bulk search is not valid' do let(:file) { nil } @@ -94,5 +108,7 @@ ]) end end + + end end \ No newline at end of file