From b37e6fc3be086f965407a06cbedd567f2296ceac Mon Sep 17 00:00:00 2001 From: Iain McNulty Date: Fri, 20 Dec 2024 09:09:22 +0000 Subject: [PATCH] Switch on ratifying provider description in API response --- app/serializers/api/public/v1/serializable_course.rb | 6 +++++- .../api/public/v1/serializable_course_spec.rb | 10 ++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/serializers/api/public/v1/serializable_course.rb b/app/serializers/api/public/v1/serializable_course.rb index b844ac4b56..b829421aa2 100644 --- a/app/serializers/api/public/v1/serializable_course.rb +++ b/app/serializers/api/public/v1/serializable_course.rb @@ -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 diff --git a/spec/serializers/api/public/v1/serializable_course_spec.rb b/spec/serializers/api/public/v1/serializable_course_spec.rb index b42d36a073..4e2060eacf 100644 --- a/spec/serializers/api/public/v1/serializable_course_spec.rb +++ b/spec/serializers/api/public/v1/serializable_course_spec.rb @@ -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) }