diff --git a/app/components/find/courses/about_schools_component/view.html.erb b/app/components/find/courses/about_schools_component/view.html.erb index 438feac8d3..1809100f21 100644 --- a/app/components/find/courses/about_schools_component/view.html.erb +++ b/app/components/find/courses/about_schools_component/view.html.erb @@ -1,7 +1,7 @@
You’ll be placed in schools for most of your course. Your school placements will be within commuting distance.
@@ -10,7 +10,7 @@Universities can work with over 100 potential placement schools. Most will be within 10 miles of the university, but sometimes they can cover a wider area, especially outside of cities.
<% end %> - <% elsif course.program_type == "scitt_programme" && course.provider.provider_code != "E65" %> + <% elsif show_scitt_guidance? %> <%= render Find::Utility::AdviceComponent::View.new(title: "Where you will train") do %>You’ll be placed in different schools during your training. You can’t pick which schools you want to be in, but your training provider will place you in schools you can travel to.
<% end %> diff --git a/app/components/find/courses/about_schools_component/view.rb b/app/components/find/courses/about_schools_component/view.rb index 8f45d34e21..bb6c95512d 100644 --- a/app/components/find/courses/about_schools_component/view.rb +++ b/app/components/find/courses/about_schools_component/view.rb @@ -21,11 +21,28 @@ def initialize(course) def render? published_how_school_placements_work.present? || - program_type == 'higher_education_programme' || - program_type == 'scitt_programme' || + program_type.in?(%w[higher_education_programme scitt_programme]) || study_sites.any? || site_statuses.map(&:site).uniq.many? || preview?(params) end + + def show_higher_education_guidance? + return false unless course.higher_education_programme? + + course_information_config.show_placement_guidance?(:program_type) + end + + def show_scitt_guidance? + return false unless course.scitt_programme? + + course_information_config.show_placement_guidance?(:program_type) + end + + private + + def course_information_config + @course_information_config ||= Configs::CourseInformation.new(course) + end end end end diff --git a/app/components/find/courses/contact_details_component/view.html.erb b/app/components/find/courses/contact_details_component/view.html.erb index d14489b8eb..1bd0ecd30a 100644 --- a/app/components/find/courses/contact_details_component/view.html.erb +++ b/app/components/find/courses/contact_details_component/view.html.erb @@ -3,12 +3,10 @@You’ll be placed in schools for most of your course. Your school placements will be within commuting distance.
You cannot pick which schools you want to be in, but your university will try to take your journey time into consideration.
Universities can work with over 100 potential placement schools. Most will be within 10 miles of the university, but sometimes they can cover a wider area, especially outside of cities.
<% end %> - <% elsif @course.program_type == 'scitt_programme' && @provider.provider_code != 'E65' %> + <% elsif show_scitt_guidance? %> <%= govuk_details(summary_text: "See the guidance we show in this section") do %>You’ll be placed in different schools during your training. You can’t pick which schools you want to be in, but your training provider will place you in schools you can travel to.
diff --git a/config/course_information.yml b/config/course_information.yml new file mode 100644 index 0000000000..00ecb7b09f --- /dev/null +++ b/config/course_information.yml @@ -0,0 +1,20 @@ +shared: + placements: + provider_type: + university: + except_provider_codes: + - B31 + program_type: + scitt_programme: + except_provider_codes: + - E65 + higher_education_programme: + except_provider_codes: + - B31 + show_address: + only_provider_codes: + - 28T + only_course_codes: + - X104 + contact_forms: + U80: https://www.ucl.ac.uk/prospective-students/graduate/admissions-enquiries diff --git a/spec/components/find/courses/about_schools_component/view_preview.rb b/spec/components/find/courses/about_schools_component/view_preview.rb index f24b0688ac..5c5c64be0c 100644 --- a/spec/components/find/courses/about_schools_component/view_preview.rb +++ b/spec/components/find/courses/about_schools_component/view_preview.rb @@ -56,6 +56,10 @@ class FakeCourse include ActiveModel::Model attr_accessor(:provider, :published_how_school_placements_work, :placements_heading, :program_type, :study_sites, :site_statuses) + def higher_education_programme? + true + end + def preview_site_statuses site_statuses.sort_by { |status| status.site.location_name } end diff --git a/spec/components/find/courses/contact_details_component/view_spec.rb b/spec/components/find/courses/contact_details_component/view_spec.rb index 684fa22d53..5eb5d6bf25 100644 --- a/spec/components/find/courses/contact_details_component/view_spec.rb +++ b/spec/components/find/courses/contact_details_component/view_spec.rb @@ -76,4 +76,16 @@ expect(result.text).to include('LSJS', '44A Albert Road', 'London', 'NW4 2SJ') end end + + context 'when the provider has a contact form in the config' do + it 'renders the Contact Form instead of Email' do + provider = build(:provider, provider_code: 'U80') + course = build(:course, course_code: 'X104', provider:).decorate + + result = render_inline(described_class.new(course)) + + expect(result.text).to include('Contact form') + expect(result.text).not_to include('Email') + end + end end diff --git a/spec/features/publish/courses/editing_course_information_guidance_spec.rb b/spec/features/publish/courses/editing_course_information_guidance_spec.rb new file mode 100644 index 0000000000..b47098844d --- /dev/null +++ b/spec/features/publish/courses/editing_course_information_guidance_spec.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true + +require 'rails_helper' + +feature 'Guidance components on course edit page', { can_edit_current_and_next_cycles: false } do + describe 'university providers' do + context 'when provider is excluded via config' do + scenario 'Guidance is not shown' do + given_a_provider_which_does_not_show_guidance + and_the_provider_has_a_course + and_i_am_authenticated_as_a_provider_user + when_i_go_to_edit_a_course + i_do_not_see_the_guidance_text + end + + def given_a_provider_which_does_not_show_guidance + @provider = create(:provider, :university, provider_code: 'B31') + end + end + + context 'when provider is not excluded via config' do + scenario 'Guidance is shown' do + given_a_provider_which_does_show_guidance + and_the_provider_has_a_course + and_i_am_authenticated_as_a_provider_user + when_i_go_to_edit_a_course + i_do_see_the_guidance_text + end + + def given_a_provider_which_does_show_guidance + @provider = create(:provider, :university, provider_code: 'XXX') + end + end + end + + describe 'scitt courses' do + context 'when provider is excluded via config' do + scenario 'Guidance is not shown' do + given_a_provider_which_does_not_show_guidance + and_the_provider_has_a_course + and_i_am_authenticated_as_a_provider_user + when_i_go_to_edit_a_course + i_do_not_see_the_guidance_text + end + + def given_a_provider_which_does_not_show_guidance + @provider = create(:provider, :scitt, provider_code: 'E65') + end + end + + context 'when provider is not excluded via config' do + scenario 'Guidance is shown' do + given_a_provider_which_does_show_guidance + and_the_provider_has_a_course + and_i_am_authenticated_as_a_provider_user + when_i_go_to_edit_a_course + i_do_see_the_guidance_text + end + + def and_the_provider_has_a_course + @course = create(:course, :with_scitt, provider: @provider) + end + + def given_a_provider_which_does_show_guidance + @provider = create(:provider, :scitt, provider_code: 'T92') + end + end + end + + def and_the_provider_has_a_course + @course = create(:course, provider: @provider) + end + + def and_i_am_authenticated_as_a_provider_user + given_i_am_authenticated + @current_user.providers << @provider + end + + def when_i_go_to_edit_a_course + publish_course_information_edit_page.load( + provider_code: @provider.provider_code, recruitment_cycle_year: @provider.recruitment_cycle_year, course_code: @course.course_code + ) + end + + def i_do_not_see_the_guidance_text + expect(page).to have_no_content('Where you will train') + end + + def i_do_see_the_guidance_text + expect(page).to have_content('Where you will train') + end +end diff --git a/spec/services/configs/course_information_spec.rb b/spec/services/configs/course_information_spec.rb new file mode 100644 index 0000000000..55537532cf --- /dev/null +++ b/spec/services/configs/course_information_spec.rb @@ -0,0 +1,150 @@ +# frozen_string_literal: true + +require 'rails_helper' + +describe Configs::CourseInformation do + let(:scitt_provider) { build(:provider, :scitt, provider_code:) } + let(:university_provider) { build(:provider, :university, provider_code:) } + + let(:he_course) { build(:course, :with_higher_education, provider:, course_code:) } + let(:scitt_course) { build(:course, :with_scitt, provider:, course_code:) } + + let(:provider_code) { 'XXX' } + let(:course_code) { 'XXX' } + + describe '#show_placement_guidance?' do + let(:course) { scitt_course } + let(:provider) { university_provider } + let(:type) { :provider_type } + + context 'when University providers provider code is present' do + let(:provider_code) { 'B31' } + + it 'returns false' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(false) + end + end + + context 'when University providers provider_code is absent' do + it 'returns true' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(true) + end + end + + context 'when SCITT course with provider_code present' do + let(:provider) { scitt_provider } + let(:type) { :program_type } + let(:provider_code) { 'E65' } + + it 'returns false' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(false) + end + end + + context 'when SCITT course with provider_code absent' do + let(:provider) { scitt_provider } + let(:type) { :program_type } + + it 'returns true' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(true) + end + end + + context 'when Higher Education course with provider_code present' do + let(:course) { he_course } + let(:provider) { scitt_provider } + let(:type) { :program_type } + let(:provider_code) { 'B31' } + + it 'returns false' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(false) + end + end + + context 'when Higher Education course with provider_code absent' do + let(:course) { he_course } + let(:provider) { scitt_provider } + let(:type) { :program_type } + + it 'returns true' do + obj = described_class.new(course) + + expect(obj.show_placement_guidance?(type)).to be(true) + end + end + end + + describe '#contact_form?' do + let(:provider) { scitt_provider } + let(:course) { scitt_course } + + context 'when provider has a contact form' do + let(:provider_code) { 'U80' } + + it 'returns true' do + obj = described_class.new(course) + + expect(obj.contact_form?).to be(true) + end + end + + context 'when provider does not have a contact form' do + it 'returns false' do + obj = described_class.new(course) + + expect(obj.contact_form?).to be(false) + end + end + end + + describe '#contact_form' do + let(:provider) { scitt_provider } + let(:course) { scitt_course } + + context 'when provider has a contact form' do + let(:provider_code) { 'U80' } + + it 'returns the contact form URL' do + obj = described_class.new(course) + + expect(obj.contact_form).to eq('https://www.ucl.ac.uk/prospective-students/graduate/admissions-enquiries') + end + end + + context 'when provider does not have a contact form' do + it 'returns false' do + obj = described_class.new(course) + + expect(obj.contact_form).to be_nil + end + end + end + + describe '#show_address?' do + subject { described_class.new(course).show_address? } + + let(:provider) { scitt_provider } + let(:course) { scitt_course } + + context 'when course and provider codes exist' do + let(:provider_code) { '28T' } + let(:course_code) { 'X104' } + + it { is_expected.to be(true) } + end + + context 'when course and provider codes do not exist' do + it { is_expected.to be(false) } + end + end +end