Skip to content

Commit

Permalink
Merge pull request #813 from DFE-Digital/format-bulk-search-query
Browse files Browse the repository at this point in the history
Parse the date of birth field for a bulk search
  • Loading branch information
felixclack authored Sep 4, 2024
2 parents 509d746 + 21df4ce commit 7e12f1c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/bulk_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 16 additions & 0 deletions spec/models/bulk_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand All @@ -94,5 +108,7 @@
])
end
end


end
end

0 comments on commit 7e12f1c

Please sign in to comment.