Skip to content

Commit

Permalink
Merge pull request #4375 from DFE-Digital/1990-bug-unable-to-add-a-le…
Browse files Browse the repository at this point in the history
…vel-info-from-the-preview-page-in-publish

Add link to add A levels requirements from preview page
  • Loading branch information
tomas-stefano authored Jul 16, 2024
2 parents bd5e890 + 01d9183 commit 6554b30
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<% end %>
<% end %>

<%= render Find::Courses::TeacherDegreeApprenticeshipEntryRequirements::View.new(course:) %>
<%= render Find::Courses::TeacherDegreeApprenticeshipEntryRequirements::View.new(course:, preview: preview?(params)) %>

<% if (course.accept_pending_gcse.nil? || course.accept_gcse_equivalency.nil?) %>
<%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :gcse, is_preview: preview?(params)) %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
<h4 class="govuk-heading-s">A levels</h4>

<%= render Find::Courses::ALevelComponent::View.new(course:) %>
<% if any_a_levels_answered? %>
<%= render Find::Courses::ALevelComponent::View.new(course:) %>
<% else %>
<%= govuk_inset_text do %>
<%= govuk_link_to t("components.course_preview.missing_information.a_levels.text"),
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 %>

<h4 class="govuk-heading-s">GCSEs</h4>
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ module Find
module Courses
module TeacherDegreeApprenticeshipEntryRequirements
class View < ViewComponent::Base
attr_reader :course
A_LEVEL_ATTRIBUTES = %i[a_level_subject_requirements accept_pending_gcse accept_a_level_equivalency additional_a_level_equivalencies].freeze
attr_reader :course, :preview

def initialize(course:)
def initialize(course:, preview:)
@course = course
@preview = preview

super
end

def render?
course.teacher_degree_apprenticeship?
end

def any_a_levels_answered?
!preview || A_LEVEL_ATTRIBUTES.any? { |attribute| course.public_send(attribute).present? }
end
end
end
end
Expand Down
2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ en:
missing_information:
about_this_course:
text: "Enter course summary"
a_levels:
text: "Enter A levels and equivalency test requirements"
degree:
text: "Enter degree requirements"
fee_uk_eu:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

describe Find::Courses::TeacherDegreeApprenticeshipEntryRequirements::View do
let(:course) { build(:course) }
let(:result) { render_inline(described_class.new(course: course.decorate)) }
let(:preview) { false }
let(:result) { render_inline(described_class.new(course: course.decorate, preview:)) }

context 'when teacher degree apprenticeship course' do
let(:course) do
Expand Down Expand Up @@ -41,20 +42,45 @@
end
end

context 'when there are no A levels' do
context 'when preview and there are no A levels' do
let(:preview) { true }
let(:course) do
build(
:course,
:with_teacher_degree_apprenticeship,
:resulting_in_undergraduate_degree_with_qts,
a_level_subject_requirements: [],
accept_pending_gcse: nil,
accept_a_level_equivalency: nil,
additional_a_level_equivalencies: nil
)
end

it 'renders the headings and enter A levels text' do
expect(result.text.gsub(/\r?\n/, ' ').squeeze(' ').strip).to eq(
'A levels Enter A levels and equivalency test requirements GCSEs'
)
end
end

context 'when not preview and there are no A levels' do
let(:preview) { false }
let(:course) do
build(
:course,
:with_teacher_degree_apprenticeship,
:resulting_in_undergraduate_degree_with_qts,
a_level_subject_requirements: [],
accept_pending_gcse: nil,
accept_a_level_equivalency: nil,
additional_a_level_equivalencies: nil
)
end

it 'renders the headings' do
expect(result.text.gsub(/\r?\n/, ' ').squeeze(' ').strip).to eq('A levels GCSEs')
expect(result.text.gsub(/\r?\n/, ' ').squeeze(' ').strip).to eq(
'A levels GCSEs'
)
end
end
end

0 comments on commit 6554b30

Please sign in to comment.