Skip to content

Commit

Permalink
Switch on ratifying provider description in API response
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed Dec 20, 2024
1 parent 2fddfcf commit b37e6fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/serializers/api/public/v1/serializable_course.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ def enrichment_attribute(name, enrichment_name = name)
:degree_type

attribute :about_accredited_body do
@object.accrediting_provider_description
if Settings.features.provider_partnerships
@object.ratifying_provider_description
else
@object.accrediting_provider_description
end
end

attribute :accredited_body_code do
Expand Down
10 changes: 10 additions & 0 deletions spec/serializers/api/public/v1/serializable_course_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@

context 'when there is an accredited body with enrichments' do
before do
allow(Settings.features).to receive(:provider_partnerships).and_return(false)
course.provider.update(accrediting_provider_enrichments: [{ Description: 'foo', UcasProviderCode: course.accrediting_provider.provider_code }])
end

it { is_expected.to have_attribute(:about_accredited_body).with_value(course.provider.accrediting_provider_enrichments.first.Description) }
end

context 'when there is a ratifying provider with description' do
before do
allow(Settings.features).to receive(:provider_partnerships).and_return(true)
course.provider.accredited_partnerships.create(description: 'foo', accredited_provider: course.accrediting_provider)
end

it { is_expected.to have_attribute(:about_accredited_body).with_value(course.provider.accredited_partnerships.find_by(accredited_provider_id: course.accrediting_provider).description) }
end

it { is_expected.to have_attribute(:about_accredited_body).with_value(nil) }
it { is_expected.to have_attribute(:about_course).with_value(course.latest_published_enrichment.about_course) }
it { is_expected.to have_attribute(:accredited_body_code).with_value(course.accredited_provider_code) }
Expand Down

0 comments on commit b37e6fc

Please sign in to comment.