Skip to content

Commit

Permalink
Merge pull request #9530 from DFE-Digital/dy-add-other_uk_qualificati…
Browse files Browse the repository at this point in the history
…on_type-to-vendor-api

Added `other_uk_qualification_type` to Vendor API
  • Loading branch information
dcyoung-dev authored Jul 19, 2024
2 parents e32a867 + ec64302 commit 932cc24
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
18 changes: 15 additions & 3 deletions app/presenters/concerns/qualification_api_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ def include_completing_qualification?
false
end

def exclude_completing_qualification?
!include_completing_qualification?
end

def qualifications_of_level(level)
application_form.application_qualifications.select do |qualification|
qualification.level == level
Expand Down Expand Up @@ -151,12 +155,20 @@ def structured_gcse_to_hashes(gcse)
private

def completing_qualification(qualification)
return {} unless include_completing_qualification? && qualification.gcse?
return {} if exclude_completing_qualification?

return completing_gcse(qualification) if qualification.gcse?

{
currently_completing_qualification: qualification[:currently_completing_qualification],
missing_explanation: qualification[:missing_explanation],
other_uk_qualification_type: qualification[:other_uk_qualification_type],
}
end

def completing_gcse(gcse_qualification)
{
currently_completing_qualification: gcse_qualification[:currently_completing_qualification],
missing_explanation: gcse_qualification[:missing_explanation],
other_uk_qualification_type: gcse_qualification[:other_uk_qualification_type],
}
end
end
24 changes: 21 additions & 3 deletions spec/presenters/vendor_api/v1.4/application_presenter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@
let(:application_form) { create(:application_form, :submitted) }
let(:application_choice) { create(:application_choice, application_form:) }

describe '#GCSEs' do
subject(:gcse) { attributes[:qualifications][:gcses].first }
describe 'qualifications' do
context 'when the application has a other_uk_qualification_type qualification' do
subject(:other_qualification) { attributes[:qualifications][:other_qualifications].first }

before do
create(
:other_qualification,
other_uk_qualification_type: 'Equivalency test',
application_form: application_form,
)
end

it 'returns the correct other_uk_qualification_type field' do
expect(other_qualification[:other_uk_qualification_type]).to eq 'Equivalency test'
expect(other_qualification).not_to have_key(:currently_completing_qualification)
expect(other_qualification).not_to have_key(:missing_explanation)
end
end

context 'when the application has a missing_and_currently_completing GCSE' do
subject(:gcse) { attributes[:qualifications][:gcses].first }

context 'when the application has a missing_and_currently_completing qualification' do
before do
create(
:gcse_qualification,
Expand Down

0 comments on commit 932cc24

Please sign in to comment.