Skip to content

Commit

Permalink
Point to A level list from description tag when A level is present
Browse files Browse the repository at this point in the history
When there is at least one A level requirement we should be
pointing to the list step and not the add more requirements page
  • Loading branch information
tomas-stefano committed Jul 9, 2024
1 parent 8590890 commit 400ca12
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
16 changes: 16 additions & 0 deletions app/decorators/course_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,22 @@ def open_or_closed_for_applications
object.open_for_applications? ? 'Open' : 'Closed'
end

def a_level_change_path
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,
object.provider.recruitment_cycle_year,
object.course_code
)
else
h.publish_provider_recruitment_cycle_course_a_levels_what_a_level_is_required_path(
object.provider.provider_code,
object.provider.recruitment_cycle_year,
object.course_code
)
end
end

def outcome
I18n.t("edit_options.qualifications.#{object.qualification}.label")
end
Expand Down
6 changes: 1 addition & 5 deletions app/views/publish/courses/_description_content.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,7 @@
t("publish.providers.courses.description_content.a_levels_label"),
(render ALevelRowComponent.new(course:, errors: @errors)),
%w[a_level_subject_requirements accept_pending_a_level accept_a_level_equivalency],
action_path: publish_provider_recruitment_cycle_course_a_levels_what_a_level_is_required_path(
@provider.provider_code,
@provider.recruitment_cycle_year,
course.course_code
),
action_path: course.a_level_change_path,
action_visually_hidden_text: "A levels",
render_errors: false
) %>
Expand Down
44 changes: 44 additions & 0 deletions spec/decorators/course_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
require 'rails_helper'

describe CourseDecorator do
include Rails.application.routes.url_helpers

let(:current_recruitment_cycle) { build_stubbed(:recruitment_cycle) }
let(:next_recruitment_cycle) { build_stubbed(:recruitment_cycle, :next) }
let(:provider) { build_stubbed(:provider, recruitment_cycle: current_recruitment_cycle) }
Expand Down Expand Up @@ -957,6 +959,48 @@
end
end

describe '#a_level_change_path' do
subject(:a_level_change_path) { course.decorate.a_level_change_path }

context 'when course does not have an A level subject requirement' do
let(:course) do
build(
:course,
a_level_subject_requirements: []
)
end

it 'returns the first page of A levels' do
expect(a_level_change_path).to eq(
publish_provider_recruitment_cycle_course_a_levels_what_a_level_is_required_path(
course.provider.provider_code,
course.provider.recruitment_cycle_year,
course.course_code
)
)
end
end

context 'when course has at least one A level subject requirement' do
let(:course) do
build(
:course,
:with_a_level_requirements
)
end

it 'returns the A level list page' do
expect(a_level_change_path).to eq(
publish_provider_recruitment_cycle_course_a_levels_add_a_level_to_a_list_path(
course.provider.provider_code,
course.provider.recruitment_cycle_year,
course.course_code
)
)
end
end
end

describe '#financial_incentive_details' do
subject { course.decorate.financial_incentive_details }

Expand Down

0 comments on commit 400ca12

Please sign in to comment.