From deddbac30096d08a91fe8b5b794b782086684ee0 Mon Sep 17 00:00:00 2001 From: Tomas D'Stefano Date: Tue, 9 Jul 2024 13:43:18 +0100 Subject: [PATCH] Don't show the A level change link when the course is withdrawn --- app/decorators/course_decorator.rb | 2 ++ spec/decorators/course_decorator_spec.rb | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/app/decorators/course_decorator.rb b/app/decorators/course_decorator.rb index b31ea4a6fe..1ba74b0621 100644 --- a/app/decorators/course_decorator.rb +++ b/app/decorators/course_decorator.rb @@ -48,6 +48,8 @@ def open_or_closed_for_applications end def a_level_change_path + return if object.is_withdrawn? + if object.a_level_subject_requirements.present? h.publish_provider_recruitment_cycle_course_a_levels_add_a_level_to_a_list_path( object.provider.provider_code, diff --git a/spec/decorators/course_decorator_spec.rb b/spec/decorators/course_decorator_spec.rb index 8a71a668b1..10742db4b7 100644 --- a/spec/decorators/course_decorator_spec.rb +++ b/spec/decorators/course_decorator_spec.rb @@ -962,6 +962,20 @@ describe '#a_level_change_path' do subject(:a_level_change_path) { course.decorate.a_level_change_path } + context 'when course is withdrawn' do + let(:course) do + build( + :course, + :with_a_level_requirements, + :withdrawn + ) + end + + it 'returns nil' do + expect(a_level_change_path).to be_nil + end + end + context 'when course does not have an A level subject requirement' do let(:course) do build(