From f9f495966e9c26b00f77773aef75fd766befdc21 Mon Sep 17 00:00:00 2001 From: CatalinVoineag <11318084+CatalinVoineag@users.noreply.github.com> Date: Thu, 4 Jul 2024 13:30:25 +0100 Subject: [PATCH] Add provider & accrediting_provider views course The course show page for find and publish(preview page) has too much content. This commit tries to reduce this content by putting the provider of the course and the accrediting provider of the course into their own views. For this to happen we also needed to change the logic of the redirects/back links when adding a provider through the course show page. You can do this when you have a draft course but without a provider. --- .../missing_information_component.rb | 2 +- .../courses/about_schools_component/view.rb | 14 +- .../contact_details_component/view.html.erb | 4 +- .../courses/contents_component/view.html.erb | 4 - .../view.html.erb | 110 ++++++++-------- .../courses/summary_component/view.html.erb | 86 +++++++----- .../find/courses/summary_component/view.rb | 25 ++++ app/controllers/concerns/goto_preview.rb | 1 + .../accrediting_providers_controller.rb | 17 +++ .../find/courses/providers_controller.rb | 19 +++ .../courses/accredited_provider_controller.rb | 6 +- .../publish/courses/providers_controller.rb | 20 +++ .../publish/providers_controller.rb | 12 +- app/helpers/find/goto_preview_helper.rb | 8 ++ app/helpers/preview_helper.rb | 4 +- .../_about_accrediting_provider.html.erb | 11 ++ .../find/courses/_about_the_provider.html.erb | 31 ++--- .../accrediting_providers/show.html.erb | 21 +++ .../find/courses/providers/show.html.erb | 25 ++++ app/views/find/courses/show.html.erb | 9 +- .../courses/accredited_provider/show.html.erb | 22 ++++ app/views/publish/courses/preview.html.erb | 8 +- .../publish/courses/providers/show.html.erb | 24 ++++ app/views/publish/providers/about.html.erb | 11 +- config/locales/en.yml | 10 ++ config/locales/find.yml | 29 +++- config/routes/find.rb | 5 + config/routes/publish.rb | 3 + .../missing_information_component_spec.rb | 3 +- .../about_schools_component/view_spec.rb | 8 +- .../courses/sumary_component/view_preview.rb | 14 +- .../courses/sumary_component/view_spec.rb | 8 +- .../find/results/results_component_spec.rb | 4 +- .../controllers/concerns/goto_preview_spec.rb | 22 ++++ .../find/search/viewing_a_course_spec.rb | 91 ++++++++----- .../publish/viewing_a_course_preview_spec.rb | 124 ++++++++++-------- spec/helpers/find/goto_preview_helper_spec.rb | 68 ++++++++++ 37 files changed, 638 insertions(+), 245 deletions(-) create mode 100644 app/controllers/find/courses/accrediting_providers_controller.rb create mode 100644 app/controllers/find/courses/providers_controller.rb create mode 100644 app/controllers/publish/courses/providers_controller.rb create mode 100644 app/views/find/courses/_about_accrediting_provider.html.erb create mode 100644 app/views/find/courses/accrediting_providers/show.html.erb create mode 100644 app/views/find/courses/providers/show.html.erb create mode 100644 app/views/publish/courses/accredited_provider/show.html.erb create mode 100644 app/views/publish/courses/providers/show.html.erb diff --git a/app/components/course_preview/missing_information_component.rb b/app/components/course_preview/missing_information_component.rb index 03b67aa1fb..5dcd692b6c 100644 --- a/app/components/course_preview/missing_information_component.rb +++ b/app/components/course_preview/missing_information_component.rb @@ -37,7 +37,7 @@ def fee_uk_eu_link = fees_publish_provider_recruitment_cycle_course_path(provide def gcse_link = gcses_pending_or_equivalency_tests_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true) def how_school_placements_work_link = school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true) def train_with_disability_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true, anchor: 'train-with-disability') - def train_with_us_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true, anchor: 'train-with-us') + def train_with_us_link = about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true, anchor: 'train-with-us') def about_accrediting_provider_link if accrediting_provider_present?(course) diff --git a/app/components/find/courses/about_schools_component/view.rb b/app/components/find/courses/about_schools_component/view.rb index 0eb86d659b..64b059bf8c 100644 --- a/app/components/find/courses/about_schools_component/view.rb +++ b/app/components/find/courses/about_schools_component/view.rb @@ -7,16 +7,17 @@ class View < ViewComponent::Base include PublishHelper include PreviewHelper - attr_reader :course + attr_reader :course, :preview delegate :published_how_school_placements_work, :program_type, :study_sites, :site_statuses, to: :course - def initialize(course) + def initialize(course, preview: false) super @course = course + @preview = preview end def render? @@ -39,17 +40,14 @@ def show_scitt_guidance? end def placements_url - if course.has_unpublished_changes? || (course.is_published? && course.is_running?) - URI.join( - Settings.search_ui.base_url, - find_placements_path(course.provider_code, course.course_code) - ).to_s - else + if preview placements_publish_provider_recruitment_cycle_course_path( course.provider_code, course.recruitment_cycle_year, course.course_code ) + else + find_placements_path(course.provider_code, course.course_code) 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 1bd0ecd30a..99773db3ac 100644 --- a/app/components/find/courses/contact_details_component/view.html.erb +++ b/app/components/find/courses/contact_details_component/view.html.erb @@ -1,5 +1,7 @@
-

Contact this training provider

+

+ <%= t(".heading", provider_name: course.provider_name) %> +

diff --git a/app/components/find/courses/contents_component/view.html.erb b/app/components/find/courses/contents_component/view.html.erb index 6f11a944a0..1cf8270b82 100644 --- a/app/components/find/courses/contents_component/view.html.erb +++ b/app/components/find/courses/contents_component/view.html.erb @@ -7,9 +7,6 @@ <% if how_school_placements_work.present? || program_type == "higher_education_programme" || program_type == "scitt_programme" || preview? %>
  • <%= govuk_link_to "Training locations", "#training-locations" %>
  • <% end %> - <% if provider.train_with_us.present? || about_accrediting_provider.present? || preview? %> -
  • <%= govuk_link_to "About the training provider", "#section-about-provider" %>
  • - <% end %> <% if salaried? %>
  • <%= govuk_link_to "Salary", "#section-salary" %>
  • <% end %> @@ -21,7 +18,6 @@ <% if provider.train_with_disability.present? || preview? %>
  • <%= govuk_link_to "Training with disabilities and other needs", "#section-train-with-disabilities" %>
  • <% end %> -
  • <%= govuk_link_to "Contact this training provider", "#section-contact" %>
  • <%= govuk_link_to "Support and advice", "#section-advice" %>
  • <% if course.application_status_open? %>
  • <%= govuk_link_to "Apply", "#section-apply" %>
  • <% end %> diff --git a/app/components/find/courses/qualifications_summary_component/view.html.erb b/app/components/find/courses/qualifications_summary_component/view.html.erb index 6d3fe7a3ef..3696a07aaf 100644 --- a/app/components/find/courses/qualifications_summary_component/view.html.erb +++ b/app/components/find/courses/qualifications_summary_component/view.html.erb @@ -1,58 +1,56 @@ -
    - <% case find_outcome %> - <% when "QTS" %> - <%= govuk_details(summary_text: "QTS") do %> -

    - Qualified teacher status (QTS) allows you to teach in state schools in England and may also allow you to teach in other parts of the UK. -

    -

    - It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in. -

    - <% end %> +<% case find_outcome %> +<% when "QTS" %> + <%= govuk_details(summary_text: "QTS") do %> +

    + Qualified teacher status (QTS) allows you to teach in state schools in England and may also allow you to teach in other parts of the UK. +

    +

    + It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in. +

    + <% end %> <% when "QTS with PGCE" %> - <%= govuk_details(summary_text: "QTS with PGCE") do %> -

    - You need qualified teacher status (QTS) to teach in state schools in England. QTS may also allow you to teach in other parts of the UK. -

    -

    - This course also offers a postgraduate certificate in education (PGCE). PGCE courses can include credits that count towards a master’s degree. -

    - <% end %> - <% when "PGDE with QTS" %> - <%= govuk_details(summary_text: "PGDE with QTS") do %> -

    - A postgraduate diploma in education (PGDE) with qualified teacher status (QTS) will allow you to teach in state schools in England and may allow you to teach in other parts of the UK. -

    -

    - It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in. -

    -

    - Many PGDE courses include credits towards a Master’s degree. -

    - <% end %> - <% when "PGCE" %> - <%= govuk_details(summary_text: "PGCE") do %> -

    - A postgraduate certificate in education (PGCE) is an academic qualification in education. -

    -

    - It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in. -

    -

    - This course does not lead to qualified teacher status (QTS). -

    - <% end %> - <% when "PGDE" %> - <%= govuk_details(summary_text: "PGDE") do %> -

    - A postgraduate diploma in education (PGDE) is equivalent to a postgraduate certificate in education (PGCE). -

    -

    - It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in. -

    -

    - This course does not lead to qualified teacher status (QTS). -

    - <% end %> + <%= govuk_details(summary_text: "QTS with PGCE") do %> +

    + You need qualified teacher status (QTS) to teach in state schools in England. QTS may also allow you to teach in other parts of the UK. +

    +

    + This course also offers a postgraduate certificate in education (PGCE). PGCE courses can include credits that count towards a master’s degree. +

    + <% end %> +<% when "PGDE with QTS" %> + <%= govuk_details(summary_text: "PGDE with QTS") do %> +

    + A postgraduate diploma in education (PGDE) with qualified teacher status (QTS) will allow you to teach in state schools in England and may allow you to teach in other parts of the UK. +

    +

    + It may also allow you to teach overseas, though you should always check what qualifications are needed in the country you’d like to teach in. +

    +

    + Many PGDE courses include credits towards a Master’s degree. +

    + <% end %> +<% when "PGCE" %> + <%= govuk_details(summary_text: "PGCE") do %> +

    + A postgraduate certificate in education (PGCE) is an academic qualification in education. +

    +

    + It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in. +

    +

    + This course does not lead to qualified teacher status (QTS). +

    + <% end %> +<% when "PGDE" %> + <%= govuk_details(summary_text: "PGDE") do %> +

    + A postgraduate diploma in education (PGDE) is equivalent to a postgraduate certificate in education (PGCE). +

    +

    + It’s recognised internationally, though you should always check what qualifications are needed in the country you’d like to teach in. +

    +

    + This course does not lead to qualified teacher status (QTS). +

    <% end %> -
    +<% end %> diff --git a/app/components/find/courses/summary_component/view.html.erb b/app/components/find/courses/summary_component/view.html.erb index 1e2e6fdbe0..7d99c0b831 100644 --- a/app/components/find/courses/summary_component/view.html.erb +++ b/app/components/find/courses/summary_component/view.html.erb @@ -1,49 +1,71 @@ -
    - <% if accrediting_provider.present? && (accrediting_provider.provider_code != provider.provider_code) %> -
    Accredited provider
    -
    <%= accrediting_provider.provider_name %>
    - <% end %> -
    Fee or salary
    -
    <%= course.funding %> +<%= govuk_summary_list(actions: false, classes: ['govuk-summary-list--no-border']) do |summary_list| %>i + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".fee_or_salary")) %> + <% row.with_value do %> + <%= course.funding %>
    -

    <%= course.funding_option %> -

    - - -
    Visa sponsorship
    -
    <%= visa_sponsorship_row %>
    +

    <%= course.funding_option %>

    + <% end %> + <% end %> <% unless no_fee? %> -
    Course fee
    -
    <%= course_fee_value %>
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".course_fee"))%> + <% row.with_value(text: course_fee_value) %> + <% end %> + <% end %> + + <% if length.present? %> + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".course_length")) %> + <% row.with_value(text: course_length_with_study_mode_row) %> + <% end %> <% end %> -
    Qualification
    - <%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %> <% if age_range_in_years.present? %> -
    Age range
    -
    <%= age_range_in_years_row %>
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".age_range")) %> + <% row.with_value(text: age_range_in_years_row) %> + <% end %> <% end %> - <% if length.present? %> -
    Course length
    -
    <%= course_length_with_study_mode_row %>
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".qualification")) %> + <% row.with_value do %> + <%= render Find::Courses::QualificationsSummaryComponent::View.new(find_outcome) %> + <% end %> + <% end %> + + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".provider")) %> + <% row.with_value do %> + <%= govuk_link_to course.provider_name, x_provider_url %> + <% end %> + <% end %> + + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".accredited_by")) %> + <% row.with_value do %> + <%= govuk_link_to course.accrediting_provider.provider_name, x_accrediting_provider_url %> + <% end %> <% end %> <% if show_apply_from_row? %> -
    Date you can apply from
    -
    <%= l(applications_open_from&.to_date) %>
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".date_can_apply")) %> + <% row.with_value(text: l(applications_open_from&.to_date)) %> + <% end %> <% end %> <% if start_date.present? %> -
    Date course starts
    -
    <%= l(start_date&.to_date, format: :short) %>
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".date_course_start")) %> + <% row.with_value(text: l(start_date&.to_date, format: :short)) %> + <% end %> <% end %> - <% if provider.decorate.website.present? %> -
    Website
    -
    - <%= govuk_link_to provider.decorate.website, provider.decorate.website %> -
    + <% summary_list.with_row do |row| %> + <% row.with_key(text: t(".visa_sponsorship")) %> + <% row.with_value(text: visa_sponsorship_row) %> <% end %> -
    +<% end %> diff --git a/app/components/find/courses/summary_component/view.rb b/app/components/find/courses/summary_component/view.rb index c465c4c645..7b5bf8038a 100644 --- a/app/components/find/courses/summary_component/view.rb +++ b/app/components/find/courses/summary_component/view.rb @@ -6,6 +6,7 @@ module SummaryComponent class View < ViewComponent::Base include ApplicationHelper include ::ViewHelper + include PreviewHelper attr_reader :course @@ -74,6 +75,30 @@ def no_fee? def show_apply_from_row? course.applications_open_from&.future? end + + def x_provider_url + if preview?(params) + provider_publish_provider_recruitment_cycle_course_path( + course.provider_code, + course.recruitment_cycle_year, + course.course_code + ) + else + find_provider_path(course.provider_code, course.course_code) + end + end + + def x_accrediting_provider_url + if preview?(params) + accredited_by_publish_provider_recruitment_cycle_course_path( + course.provider_code, + course.recruitment_cycle_year, + course.course_code + ) + else + find_accrediting_provider_path(course.provider_code, course.course_code) + end + end end end end diff --git a/app/controllers/concerns/goto_preview.rb b/app/controllers/concerns/goto_preview.rb index e917b78be8..e4e8cd5166 100644 --- a/app/controllers/concerns/goto_preview.rb +++ b/app/controllers/concerns/goto_preview.rb @@ -8,4 +8,5 @@ def param_form_key end def goto_preview? = params.dig(param_form_key, :goto_preview) == 'true' + def goto_provider? = params.dig(param_form_key, :goto_provider) == 'true' end diff --git a/app/controllers/find/courses/accrediting_providers_controller.rb b/app/controllers/find/courses/accrediting_providers_controller.rb new file mode 100644 index 0000000000..a16fa3b6c4 --- /dev/null +++ b/app/controllers/find/courses/accrediting_providers_controller.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Find + module Courses + class AccreditingProvidersController < Find::ApplicationController + def show + @course = provider.courses.includes( + :enrichments, + subjects: [:financial_incentive], + site_statuses: [:site] + ).find_by!(course_code: params[:course_code]&.upcase).decorate + + render_not_found if @course.accrediting_provider.blank? || !@course.is_published? + end + end + end +end diff --git a/app/controllers/find/courses/providers_controller.rb b/app/controllers/find/courses/providers_controller.rb new file mode 100644 index 0000000000..dfeee80d90 --- /dev/null +++ b/app/controllers/find/courses/providers_controller.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +module Find + module Courses + class ProvidersController < Find::ApplicationController + before_action -> { render_not_found if provider.nil? } + + def show + @course = provider.courses.includes( + :enrichments, + subjects: [:financial_incentive], + site_statuses: [:site] + ).find_by!(course_code: params[:course_code]&.upcase).decorate + + render_not_found unless @course.is_published? + end + end + end +end diff --git a/app/controllers/publish/courses/accredited_provider_controller.rb b/app/controllers/publish/courses/accredited_provider_controller.rb index 5c648d8ba0..49fcb7ec7f 100644 --- a/app/controllers/publish/courses/accredited_provider_controller.rb +++ b/app/controllers/publish/courses/accredited_provider_controller.rb @@ -3,10 +3,14 @@ module Publish module Courses class AccreditedProviderController < PublishController + include CourseBasicDetailConcern before_action :build_course, only: %i[edit update] before_action :build_course_params, only: :continue - include CourseBasicDetailConcern + def show + @course = build_course&.decorate + render_not_found if @course.accrediting_provider.blank? + end def edit build_provider diff --git a/app/controllers/publish/courses/providers_controller.rb b/app/controllers/publish/courses/providers_controller.rb new file mode 100644 index 0000000000..8a13840a4c --- /dev/null +++ b/app/controllers/publish/courses/providers_controller.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Publish + module Courses + class ProvidersController < PublishController + include CourseBasicDetailConcern + + before_action :build_course, only: %i[show] + + def show; end + + private + + def build_course + super + authorize @course + end + end + end +end diff --git a/app/controllers/publish/providers_controller.rb b/app/controllers/publish/providers_controller.rb index d9d3d88161..f1d8438794 100644 --- a/app/controllers/publish/providers_controller.rb +++ b/app/controllers/publish/providers_controller.rb @@ -63,7 +63,15 @@ def update @about_form = AboutYourOrganisationForm.new(provider, params: provider_params) if @about_form.save! - if goto_preview? + if goto_provider? + redirect_to( + provider_publish_provider_recruitment_cycle_course_path( + provider.provider_code, + provider.recruitment_cycle_year, + params[:course_code] || params.dig(param_form_key, :course_code) + ) + ) + elsif goto_preview? redirect_to preview_publish_provider_recruitment_cycle_course_path(provider.provider_code, provider.recruitment_cycle_year, (params[:course_code] || params.dig(param_form_key, :course_code))) else flash[:success] = I18n.t('success.published') @@ -116,7 +124,7 @@ def redirect_to_contact_page_with_ukprn_error def provider_params params .require(param_form_key) - .except(:goto_preview, :course_code) + .except(:goto_preview, :course_code, :goto_provider) .permit( *AboutYourOrganisationForm::FIELDS, accredited_bodies: %i[provider_name provider_code description] diff --git a/app/helpers/find/goto_preview_helper.rb b/app/helpers/find/goto_preview_helper.rb index 5526ae390d..fe136a07b0 100644 --- a/app/helpers/find/goto_preview_helper.rb +++ b/app/helpers/find/goto_preview_helper.rb @@ -10,6 +10,14 @@ def goto_preview?(param_form_key:, params:) goto_preview_value(param_form_key:, params:) == 'true' end + def goto_provider_value(param_form_key:, params:) + params[:goto_provider] || params.dig(param_form_key, :goto_provider) + end + + def goto_provider?(param_form_key:, params:) + goto_provider_value(param_form_key:, params:) == 'true' + end + def back_link_path(param_form_key:, params:, provider_code:, recruitment_cycle_year:, course_code:) if goto_preview?(param_form_key:, params:) preview_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code) diff --git a/app/helpers/preview_helper.rb b/app/helpers/preview_helper.rb index 9c20395a33..e38c033fc1 100644 --- a/app/helpers/preview_helper.rb +++ b/app/helpers/preview_helper.rb @@ -2,6 +2,8 @@ module PreviewHelper def preview?(params) - params[:action] == 'preview' || params[:action].nil? + params[:action] == 'preview' || + params[:action].nil? || + (params[:controller] == 'publish/courses/providers' && params[:action] == 'show') end end diff --git a/app/views/find/courses/_about_accrediting_provider.html.erb b/app/views/find/courses/_about_accrediting_provider.html.erb new file mode 100644 index 0000000000..b02c80807e --- /dev/null +++ b/app/views/find/courses/_about_accrediting_provider.html.erb @@ -0,0 +1,11 @@ +
    +
    +

    + <%= t(".heading", provider_name: course.accrediting_provider.provider_name) %> +

    + +
    + <%= markdown(course.about_accrediting_provider) %> +
    +
    +
    diff --git a/app/views/find/courses/_about_the_provider.html.erb b/app/views/find/courses/_about_the_provider.html.erb index d09b3ac39e..d279bb1f68 100644 --- a/app/views/find/courses/_about_the_provider.html.erb +++ b/app/views/find/courses/_about_the_provider.html.erb @@ -1,22 +1,17 @@ -
    -

    About the training provider

    - <% if course.provider.train_with_us.present? %> -
    - <%= markdown(course.provider.train_with_us) %> -
    +
    +
    +

    + <%= t(".heading", provider_name: course.provider_name) %> +

    + + <% if course.provider.train_with_us.present? %> +
    + <%= markdown(course.provider.train_with_us) %> +
    <% else %> <%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :train_with_us, is_preview: preview?(params)) %> - <% end %> - - <% if course.accrediting_provider.present? %> - <% if course.about_accrediting_provider.present? %> -

    About the accredited provider

    -
    - <%= markdown(course.about_accrediting_provider) %> -
    - <% elsif params[:action] == "preview" %> -

    About the accredited provider

    - <%= render CoursePreview::MissingInformationComponent.new(course:, information_type: :about_accrediting_provider, is_preview: preview?(params)) %> <% end %> - <% end %> +
    + + diff --git a/app/views/find/courses/accrediting_providers/show.html.erb b/app/views/find/courses/accrediting_providers/show.html.erb new file mode 100644 index 0000000000..b6907e625a --- /dev/null +++ b/app/views/find/courses/accrediting_providers/show.html.erb @@ -0,0 +1,21 @@ +<%= content_for :page_title do %> + <%= t( + ".heading", + provider_name: @course.provider_name + ) %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: search_ui_course_page_url( + provider_code: @course.provider_code, + course_code: @course.course_code + ), + text: t( + ".back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +<%= render partial: "find/courses/about_accrediting_provider", locals: { course: @course } %> diff --git a/app/views/find/courses/providers/show.html.erb b/app/views/find/courses/providers/show.html.erb new file mode 100644 index 0000000000..2d283958fc --- /dev/null +++ b/app/views/find/courses/providers/show.html.erb @@ -0,0 +1,25 @@ +<%= content_for :page_title do %> + <%= t( + ".heading", + provider_name: @course.provider_name + ) %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: search_ui_course_page_url( + provider_code: @course.provider_code, + course_code: @course.course_code + ), + text: t( + ".back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +<%= render Find::Courses::ContactDetailsComponent::View.new(@course) %> + +<% if @provider.train_with_us.present? || @course.about_accrediting_provider.present? %> + <%= render partial: "find/courses/about_the_provider", locals: { course: @course } %> +<% end %> diff --git a/app/views/find/courses/show.html.erb b/app/views/find/courses/show.html.erb index 6f8f0b0c86..76ea45d8a6 100644 --- a/app/views/find/courses/show.html.erb +++ b/app/views/find/courses/show.html.erb @@ -20,7 +20,6 @@ <%= @course.name_and_code %> -

    <%= @course.extended_qualification_descriptions %>

    @@ -40,7 +39,7 @@ <%= render partial: "find/courses/about_course", locals: { course: @course } %> <% end %> - <%= render Find::Courses::AboutSchoolsComponent::View.new(@course) %> + <%= render Find::Courses::AboutSchoolsComponent::View.new(@course, preview: preview?(params)) %> <% if @course.salaried? %> <%= render partial: "find/courses/salary", locals: { course: @course } %> @@ -48,10 +47,6 @@ <%= render Shared::Courses::FinancialSupport::FeesAndFinancialSupportComponent::View.new(@course) %> - <% if @provider.train_with_us.present? || @course.about_accrediting_provider.present? %> - <%= render partial: "find/courses/about_the_provider", locals: { course: @course } %> - <% end %> - <% if @course.published_interview_process.present? %> <%= render partial: "find/courses/interview_process", locals: { course: @course } %> <% end %> @@ -62,8 +57,6 @@ <%= render partial: "find/courses/train_with_disabilities", locals: { course: @course } %> <% end %> - <%= render Find::Courses::ContactDetailsComponent::View.new(@course) %> - <%= render partial: "find/courses/advice", locals: { course: @course } %> <% if @course.application_status_closed? %> diff --git a/app/views/publish/courses/accredited_provider/show.html.erb b/app/views/publish/courses/accredited_provider/show.html.erb new file mode 100644 index 0000000000..b8433714fc --- /dev/null +++ b/app/views/publish/courses/accredited_provider/show.html.erb @@ -0,0 +1,22 @@ +<%= content_for :page_title do %> + <%= t( + "publish.providers.courses.accredited_provider.show.heading", + provider_name: @course.accrediting_provider + ) %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: preview_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ), + text: t( + "publish.providers.courses.accredited_provider.show.back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +<%= render partial: "find/courses/about_accrediting_provider", locals: { course: @course } %> diff --git a/app/views/publish/courses/preview.html.erb b/app/views/publish/courses/preview.html.erb index f8d13b8072..089f5477c1 100644 --- a/app/views/publish/courses/preview.html.erb +++ b/app/views/publish/courses/preview.html.erb @@ -15,8 +15,6 @@ <%= course.name_and_code %> -

    <%= course.description %>

    - <%= render Find::Courses::SummaryComponent::View.new(course) %> @@ -31,7 +29,7 @@ <%= render partial: "find/courses/about_course", locals: { course: } %> - <%= render Find::Courses::AboutSchoolsComponent::View.new(course) %> + <%= render Find::Courses::AboutSchoolsComponent::View.new(course, preview: preview?(params)) %> <% if course.salaried? %> <%= render partial: "find/courses/salary", locals: { course: } %> @@ -39,8 +37,6 @@ <%= render Shared::Courses::FinancialSupport::FeesAndFinancialSupportComponent::View.new(course) %> - <%= render partial: "find/courses/about_the_provider", locals: { course: } %> - <% if course.interview_process.present? %> <%= render partial: "find/courses/interview_process", locals: { course: } %> <% end %> @@ -49,8 +45,6 @@ <%= render partial: "find/courses/train_with_disabilities", locals: { course: } %> - <%= render Find::Courses::ContactDetailsComponent::View.new(course) %> - <%= render partial: "find/courses/advice", locals: { course: } %> <%= render Find::Courses::ApplyComponent::View.new(course) unless course.application_status_open? %> diff --git a/app/views/publish/courses/providers/show.html.erb b/app/views/publish/courses/providers/show.html.erb new file mode 100644 index 0000000000..584bbb149e --- /dev/null +++ b/app/views/publish/courses/providers/show.html.erb @@ -0,0 +1,24 @@ +<%= content_for :page_title do %> + <%= t( + "publish.providers.courses.providers.show.heading", + provider_name: @course.provider_name + ) %> +<% end %> +<% content_for :before_content do %> + <%= govuk_back_link( + href: preview_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ), + text: t( + "publish.providers.courses.providers.show.back", + course_name: @course.name, + course_code: @course.course_code + ) + ) %> +<% end %> + +<%= render Find::Courses::ContactDetailsComponent::View.new(@course) %> + +<%= render partial: "find/courses/about_the_provider", locals: { course: @course } %> diff --git a/app/views/publish/providers/about.html.erb b/app/views/publish/providers/about.html.erb index 18e664f68d..e71285c913 100644 --- a/app/views/publish/providers/about.html.erb +++ b/app/views/publish/providers/about.html.erb @@ -10,7 +10,15 @@ ) do |f| %> <% content_for :before_content do %> - <% if goto_preview?(param_form_key: f.object_name.to_sym, params:) %> + <% if goto_provider?(param_form_key: f.object_name.to_sym, params:) %> + <%= govuk_back_link_to( + provider_publish_provider_recruitment_cycle_course_path( + @provider.provider_code, + @provider.recruitment_cycle_year, + params[:course_code] || params.dig(f.object_name.to_sym, :course_code) + ) + ) %> + <% elsif goto_preview?(param_form_key: f.object_name.to_sym, params:) %> <%= govuk_back_link_to(preview_publish_provider_recruitment_cycle_course_path(@provider.provider_code, @provider.recruitment_cycle_year, (params[:course_code] || params.dig(f.object_name.to_sym, :course_code)))) %> <% else %> <%= govuk_back_link_to(details_publish_provider_recruitment_cycle_path(@provider.provider_code, @provider.recruitment_cycle_year)) %> @@ -66,6 +74,7 @@ max_words: 250, rows: 15) %> <%= f.hidden_field(:goto_preview, value: goto_preview_value(param_form_key: f.object_name.to_sym, params:)) %> + <%= f.hidden_field(:goto_provider, value: goto_provider_value(param_form_key: f.object_name.to_sym, params:)) %> <%= f.hidden_field(:course_code, value: params[:course_code] || params.dig(f.object_name.to_sym, :course_code)) %> <%= f.govuk_submit "Save and publish" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index cd19855052..65c5ceca6c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,6 +1,8 @@ en: shared: courses: + provider: + heading: Contact %{provider_name} placements: heading: School placements at %{provider_name} warning: You can’t pick which schools you will be in. @@ -396,6 +398,14 @@ en: publish: providers: courses: + accredited_provider: + show: + back: Back to %{course_name} (%{course_code}) + heading: About %{provider_name} + providers: + show: + back: Back to %{course_name} (%{course_code}) + heading: Contact %{provider_name} placements: heading: School placements at %{provider_name} back: Back to %{course_name} (%{course_code}) diff --git a/config/locales/find.yml b/config/locales/find.yml index ab17efd41d..0d2ef2855f 100644 --- a/config/locales/find.yml +++ b/config/locales/find.yml @@ -17,7 +17,7 @@ en: description: Candidates can browse courses on Find. Courses returned are from the next recruitment cycle updated: Cycle schedule updated enic: - statement_of_comparability: + statement_of_comparability: url: https://www.enic.org.uk/Qualifications/SOC/Default.aspx qualifications: qts: "QTS" @@ -70,6 +70,33 @@ en: primary_title: Primary courses with subject specialisms secondary_title: Which secondary subjects do you want to teach? courses: + summary_component: + view: + fee_or_salary: Fee or salary + course_fee: Course fee + course_length: Course length + age_range: Age range + date_can_apply: Date you can apply from + date_course_start: Date course starts + qualification: Qualification + provider: Provider + accredited_by: Accredited by + visa_sponsorship: Visa sponsorship + providers: + show: + heading: About %{provider_name} + back: Back to %{course_name} (%{course_code}) + about_the_provider: + heading: About %{provider_name} + about_accrediting_provider: + heading: About %{provider_name} + accrediting_providers: + show: + heading: About %{provider_name} + back: Back to %{course_name} (%{course_code}) + contact_details_component: + view: + heading: Contact %{provider_name} about_schools_component: view: view_list_of_school_placements: View list of school placements diff --git a/config/routes/find.rb b/config/routes/find.rb index 42c9c1ddbf..7d81395f8f 100644 --- a/config/routes/find.rb +++ b/config/routes/find.rb @@ -19,6 +19,11 @@ get '/location-suggestions', to: 'location_suggestions#index' get '/cycle-has-ended', to: 'pages#cycle_has_ended', as: 'cycle_has_ended' + scope module: :courses, path: '/courses' do + get '/:provider_code/:course_code/provider', to: 'providers#show', as: :provider + get '/:provider_code/:course_code/accredited-by', to: 'accrediting_providers#show', as: :accrediting_provider + end + get '/feature-flags', to: 'feature_flags#index' post '/feature-flags' => 'feature_flags#update' get '/confirm-environment' => 'confirm_environment#new' diff --git a/config/routes/publish.rb b/config/routes/publish.rb index 258ce4b18d..a882d0e498 100644 --- a/config/routes/publish.rb +++ b/config/routes/publish.rb @@ -249,6 +249,9 @@ get '/accredited-provider', on: :member, to: 'courses/accredited_provider#edit' put '/accredited-provider', on: :member, to: 'courses/accredited_provider#update' + get '/accredited-by', on: :member, to: 'courses/accredited_provider#show' + + get '/provider', on: :member, to: 'courses/providers#show' get '/study-sites', on: :member, to: 'courses/study_sites#edit' put '/study-sites', on: :member, to: 'courses/study_sites#update' diff --git a/spec/components/course_preview/missing_information_component_spec.rb b/spec/components/course_preview/missing_information_component_spec.rb index c41748dff9..4ada7a3a53 100644 --- a/spec/components/course_preview/missing_information_component_spec.rb +++ b/spec/components/course_preview/missing_information_component_spec.rb @@ -29,7 +29,7 @@ module CoursePreview train_with_disability: "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-disability", train_with_us: - "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-us", + "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_provider: true)}#train-with-us", about_accrediting_provider: publish_provider_recruitment_cycle_accredited_providers_path(provider_code, recruitment_cycle_year) @@ -50,6 +50,7 @@ module CoursePreview include_examples 'course with missing information', :gcse, 'Enter GCSE and equivalency test requirements' include_examples 'course with missing information', :how_school_placements_work, 'Enter details about how placements work' include_examples 'course with missing information', :train_with_disability, 'Enter details about training with disabilities and other needs' + include_examples 'course with missing information', :train_with_us, 'Enter details about the training provider' include_examples 'course with missing information', :about_accrediting_provider, 'Enter details about the accredited provider' end diff --git a/spec/components/find/courses/about_schools_component/view_spec.rb b/spec/components/find/courses/about_schools_component/view_spec.rb index 21712caf1e..d5eddf6317 100644 --- a/spec/components/find/courses/about_schools_component/view_spec.rb +++ b/spec/components/find/courses/about_schools_component/view_spec.rb @@ -189,14 +189,10 @@ ).decorate result = render_inline(described_class.new(course)) - url = URI.join( - Settings.search_ui.base_url, - find_placements_path(course.provider_code, course.course_code) - ).to_s expect(result).to have_link( 'View list of school placements', - href: url + href: find_placements_path(course.provider_code, course.course_code) ) end end @@ -212,7 +208,7 @@ ] ).decorate - result = render_inline(described_class.new(course)) + result = render_inline(described_class.new(course, preview: true)) url = placements_publish_provider_recruitment_cycle_course_path( course.provider_code, course.recruitment_cycle_year, diff --git a/spec/components/find/courses/sumary_component/view_preview.rb b/spec/components/find/courses/sumary_component/view_preview.rb index 20c6add5a5..e5438856c8 100644 --- a/spec/components/find/courses/sumary_component/view_preview.rb +++ b/spec/components/find/courses/sumary_component/view_preview.rb @@ -28,6 +28,7 @@ def mock_secondary_course accrediting_provider = Provider.new(provider_name: 'University of BAT', accrediting_provider: 'accredited_provider', provider_type: 'university') FakeCourse.new(provider: Provider.new(provider_code: 'DFE', website: 'wwww.awesomeprovider@aol.com'), accrediting_provider:, + course_code: 'code', has_bursary: false, age_range_in_years: '11_to_18', course_length: 'OneYear', @@ -43,6 +44,7 @@ def mock_primary_course accrediting_provider = Provider.new(provider_name: 'University of BAT', accrediting_provider: 'accredited_provider', provider_type: 'university') FakeCourse.new(provider: Provider.new(provider_code: 'DFE', website: 'wwww.awesomeprovider@aol.com'), accrediting_provider:, + course_code: 'code', has_bursary: false, age_range_in_years: '3_to_7', course_length: 'OneYear', @@ -57,7 +59,9 @@ def mock_primary_course class FakeCourse include ActiveModel::Model - attr_accessor(:provider, :accrediting_provider, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa, :fee_uk_eu, :fee_international) + attr_accessor(:provider, :accrediting_provider, :course_code, :has_bursary, :age_range_in_years, :course_length, :applications_open_from, :start_date, :qualification, :funding_type, :subjects, :level, :can_sponsor_student_visa, :fee_uk_eu, :fee_international) + + delegate :provider_name, :provider_code, to: :provider, allow_nil: true def has_bursary? has_bursary @@ -74,6 +78,14 @@ def secondary_course? def study_mode 'full_time' end + + def has_unpublished_changes? + false + end + + def is_published? + false + end end end end diff --git a/spec/components/find/courses/sumary_component/view_spec.rb b/spec/components/find/courses/sumary_component/view_spec.rb index 82bf2b9b0d..a09a82ca18 100644 --- a/spec/components/find/courses/sumary_component/view_spec.rb +++ b/spec/components/find/courses/sumary_component/view_spec.rb @@ -13,12 +13,14 @@ module SummaryComponent result = render_inline(described_class.new(course)) expect(result.text).to include( 'Fee or salary', - 'Qualification', + 'Course fee', 'Course length', + 'Age range', 'Qualification', + 'Provider', 'Date you can apply from', 'Date course starts', - 'Website' + 'Visa sponsorship' ) end @@ -75,7 +77,7 @@ module SummaryComponent result = render_inline(described_class.new(course)) expect(result.text).to include( - 'Accredited provider' + 'Accredited by' ) end end diff --git a/spec/components/find/results/results_component_spec.rb b/spec/components/find/results/results_component_spec.rb index 0ad66adc6d..437e2c5be0 100644 --- a/spec/components/find/results/results_component_spec.rb +++ b/spec/components/find/results/results_component_spec.rb @@ -24,7 +24,7 @@ module Find ) end - let(:courses) { Course.all.page(1) } + let(:courses) { ::Course.all.page(1) } it 'renders a "No courses found" message when there are no results' do component = render_inline( @@ -57,7 +57,7 @@ module Find ) end - let(:courses) { Course.all.page(1) } + let(:courses) { ::Course.all.page(1) } before do create_list(:course, 10) diff --git a/spec/controllers/concerns/goto_preview_spec.rb b/spec/controllers/concerns/goto_preview_spec.rb index 45e25407d6..6b5ea0952e 100644 --- a/spec/controllers/concerns/goto_preview_spec.rb +++ b/spec/controllers/concerns/goto_preview_spec.rb @@ -38,4 +38,26 @@ def param_form_key = :param_form_key end end end + + describe '#goto_provider?' do + subject do + test_class.goto_provider? + end + + context 'params is empty' do + let(:params) { {} } + + it 'returns falsey' do + expect(subject).to be_falsey + end + end + + context 'params has param_form_key with goto_provider set to "true"' do + let(:params) { { param_form_key: { goto_provider: 'true' } } } + + it 'returns truthy' do + expect(subject).to be_truthy + end + end + end end diff --git a/spec/features/find/search/viewing_a_course_spec.rb b/spec/features/find/search/viewing_a_course_spec.rb index 4456eebf16..2cf62adbb8 100644 --- a/spec/features/find/search/viewing_a_course_spec.rb +++ b/spec/features/find/search/viewing_a_course_spec.rb @@ -73,6 +73,20 @@ when_i_visit_the_course_page when_i_click('View list of school placements') then_i_should_be_on_the_school_placements_page + when_i_click("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_on_the_course_page + end + + scenario 'user views provider and accredited_provider' do + given_there_is_a_findable_course + when_i_visit_the_course_page + when_i_click(@course.provider_name) + then_i_should_be_on_the_provider_page + when_i_click("Back to #{@course.name} (#{course.course_code})") + when_i_click(@course.accrediting_provider.provider_name) + then_i_should_be_on_the_accrediting_provider_page + when_i_click("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_on_the_course_page end private @@ -162,14 +176,6 @@ def then_i_should_see_the_course_information provider.provider_name ) - expect(find_course_show_page.accredited_provider).to have_content( - accrediting_provider.provider_name - ) - - expect(find_course_show_page.extended_qualification_descriptions).to have_content( - 'Qualified teacher status (QTS) with a postgraduate certificate in education (PGCE)' - ) - expect(find_course_show_page.qualifications).to have_content( 'QTS with PGCE' ) @@ -190,10 +196,6 @@ def then_i_should_see_the_course_information 'September 2022' ) - expect(find_course_show_page.provider_website).to have_content( - provider.website - ) - expect(find_course_show_page).not_to have_vacancies expect(find_course_show_page.about_course).to have_content( @@ -257,34 +259,10 @@ def then_i_should_see_the_course_information 'Certificate must be print in blue ink' ) - expect(find_course_show_page.train_with_us).to have_content( - provider.train_with_us - ) - - expect(find_course_show_page.about_accrediting_provider).to have_content( - @course.decorate.about_accrediting_provider - ) - expect(find_course_show_page.train_with_disability).to have_content( provider.train_with_disability ) - expect(find_course_show_page.contact_email).to have_content( - provider.email - ) - - expect(find_course_show_page.contact_telephone).to have_content( - provider.telephone - ) - - expect(find_course_show_page.contact_website).to have_content( - provider.website - ) - - expect(find_course_show_page.contact_address).to have_content( - [@provider.address1, @provider.address2, @provider.address3, @provider.town, @provider.address4, @provider.postcode].compact.join(' ') - ) - expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies') expect(find_course_show_page).to have_link('View list of school placements') @@ -360,4 +338,45 @@ def then_i_should_be_on_the_school_placements_page expect(find_course_show_page).to have_content(smart_quotes(site.decorate.full_address)) end end + + def then_i_should_be_on_the_provider_page + expect(find_course_show_page.train_with_us).to have_content( + provider.train_with_us + ) + + expect(find_course_show_page.contact_email).to have_content( + provider.email + ) + + expect(find_course_show_page.contact_telephone).to have_content( + provider.telephone + ) + + expect(find_course_show_page.contact_website).to have_content( + provider.website + ) + + expect(find_course_show_page.contact_address).to have_content( + [@provider.address1, @provider.address2, @provider.address3, @provider.town, @provider.address4, @provider.postcode].compact.join(' ') + ) + end + + def then_i_should_be_on_the_accrediting_provider_page + expect(find_course_show_page.about_accrediting_provider).to have_content( + @course.decorate.about_accrediting_provider + ) + + expect(find_course_show_page).to have_content( + accrediting_provider.provider_name + ) + end + + def then_i_should_be_on_the_course_page + expect(page.current_url).to eq( + URI.join( + Settings.search_ui.base_url, + "/course/#{@course.provider_code}/#{@course.course_code}" + ).to_s + ) + end end diff --git a/spec/features/publish/viewing_a_course_preview_spec.rb b/spec/features/publish/viewing_a_course_preview_spec.rb index d58344597e..513b5df0bf 100644 --- a/spec/features/publish/viewing_a_course_preview_spec.rb +++ b/spec/features/publish/viewing_a_course_preview_spec.rb @@ -22,14 +22,15 @@ scenario 'blank about the training provider' do given_i_am_authenticated(user: user_with_no_course_enrichments) when_i_visit_the_publish_course_preview_page + and_i_click_link_or_button(@course.provider_name) and_i_click_link_or_button('Enter details about the training provider') then_i_should_be_on_about_your_organisation_page and_i_click_link_or_button('Back') - then_i_should_be_back_on_the_preview_page + then_i_should_be_back_on_the_provider_page and_i_click_link_or_button('Enter details about the training provider') then_i_see_markdown_formatting_guidance_for_each_field and_i_submit_a_valid_about_your_organisation - then_i_should_be_back_on_the_preview_page + then_i_should_be_back_on_the_provider_page then_i_should_see_the_updated_content('test training with your organisation') end @@ -123,6 +124,7 @@ user: user_with_custom_address_requested_via_zendesk ) when_i_visit_the_publish_course_preview_page + and_i_click_link_or_button(@course.provider_name) then_i_see_custom_address end end @@ -130,8 +132,22 @@ scenario 'user views school placements' do given_i_am_authenticated(user: user_with_fee_based_course) when_i_visit_the_publish_course_preview_page - when_i_click('View list of school placements') + and_i_click_link_or_button('View list of school placements') then_i_should_be_on_the_school_placements_page + and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_back_on_the_preview_page + end + + scenario 'user views provider and accredited_provider' do + given_i_am_authenticated(user: user_with_fee_based_course) + when_i_visit_the_publish_course_preview_page + and_i_click_link_or_button(@course.provider_name) + then_i_should_be_on_the_provider_page + and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})") + and_i_click_link_or_button(@course.accrediting_provider.provider_name) + then_i_should_be_on_the_accrediting_provider_page + and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_back_on_the_preview_page end private @@ -163,14 +179,6 @@ def then_i_see_the_course_preview_details provider.provider_name ) - expect(publish_course_preview_page.accredited_provider).to have_content( - accrediting_provider.provider_name - ) - - expect(publish_course_preview_page.description).to have_content( - course.decorate.description - ) - expect(publish_course_preview_page.qualifications).to have_content( 'QTS with PGCE' ) @@ -195,10 +203,6 @@ def then_i_see_the_course_preview_details "September #{recruitment_cycle.year}" ) - expect(publish_course_preview_page.provider_website).to have_content( - provider.website - ) - expect(publish_course_preview_page).not_to have_vacancies expect(publish_course_preview_page.about_course).to have_content( @@ -235,49 +239,13 @@ def then_i_see_the_course_preview_details 'Financial support from the training provider' ) - expect(publish_course_preview_page.train_with_us).to have_content( - provider.train_with_us - ) - - expect(publish_course_preview_page.about_accrediting_provider).to have_content( - decorated_course.about_accrediting_provider - ) - expect(publish_course_preview_page.train_with_disability).to have_content( provider.train_with_disability ) - expect(publish_course_preview_page.contact_email).to have_content( - provider.email - ) - - expect(publish_course_preview_page.contact_telephone).to have_content( - provider.telephone - ) - expect(publish_course_preview_page).to have_content '2:1 or above, or equivalent' expect(publish_course_preview_page).to have_content 'Maths A level' - expect(publish_course_preview_page.contact_website).to have_content( - provider.website - ) - - expect(publish_course_preview_page.contact_address).to have_content( - provider.address1 - ) - expect(publish_course_preview_page.contact_address).to have_content( - provider.address2 - ) - expect(publish_course_preview_page.contact_address).to have_content( - provider.address3 - ) - expect(publish_course_preview_page.contact_address).to have_content( - provider.town - ) - expect(publish_course_preview_page.contact_address).to have_content( - provider.address4 - ) - expect(publish_course_preview_page).to have_study_sites_table expect(publish_course_preview_page).to have_link('View list of school placements') @@ -430,6 +398,12 @@ def then_i_should_be_back_on_the_preview_page expect(page).to have_current_path "/publish/organisations/#{provider.provider_code}/#{provider.recruitment_cycle_year}/courses/#{course.course_code}/preview" end + def then_i_should_be_back_on_the_provider_page + expect(page).to have_current_path( + "/publish/organisations/#{provider.provider_code}/#{provider.recruitment_cycle_year}/courses/#{course.course_code}/provider" + ) + end + def and_i_submit_a_valid_about_your_organisation fill_in 'Training with your organisation', with: 'test training with your organisation' fill_in 'Training with disabilities and other needs', with: 'test training with disabilities' @@ -483,11 +457,51 @@ def and_i_do_not_see_financial_support expect(publish_course_preview_page).not_to have_bursary_amount end - def when_i_click(button) - click_on(button) - end - def then_i_should_be_on_the_school_placements_page expect(publish_course_preview_page).to have_school_placements_table end + + def then_i_should_be_on_the_provider_page + expect(publish_course_preview_page.train_with_us).to have_content( + provider.train_with_us + ) + + expect(publish_course_preview_page.contact_email).to have_content( + provider.email + ) + + expect(publish_course_preview_page.contact_telephone).to have_content( + provider.telephone + ) + + expect(publish_course_preview_page.contact_website).to have_content( + provider.website + ) + + expect(publish_course_preview_page.contact_address).to have_content( + provider.address1 + ) + expect(publish_course_preview_page.contact_address).to have_content( + provider.address2 + ) + expect(publish_course_preview_page.contact_address).to have_content( + provider.address3 + ) + expect(publish_course_preview_page.contact_address).to have_content( + provider.town + ) + expect(publish_course_preview_page.contact_address).to have_content( + provider.address4 + ) + end + + def then_i_should_be_on_the_accrediting_provider_page + expect(page).to have_content( + accrediting_provider.provider_name + ) + + expect(publish_course_preview_page.about_accrediting_provider).to have_content( + decorated_course.about_accrediting_provider + ) + end end diff --git a/spec/helpers/find/goto_preview_helper_spec.rb b/spec/helpers/find/goto_preview_helper_spec.rb index bd9ccaa373..58662b3a6a 100644 --- a/spec/helpers/find/goto_preview_helper_spec.rb +++ b/spec/helpers/find/goto_preview_helper_spec.rb @@ -66,6 +66,74 @@ module Find end end + describe '#goto_provider_value' do + subject do + goto_provider_value(param_form_key:, params:) + end + + context 'params is empty' do + let(:params) { {} } + + it 'returns falsey' do + expect(subject).to be_nil + end + end + + context 'params has goto_provider set to "true"' do + let(:params) { { goto_provider: 'true' } } + + it 'returns truthy' do + expect(subject).to eq('true') + end + end + + context 'params has param_form_key with goto_provider set to "true"' do + let(:params) { { param_form_key: { goto_provider: 'true' } } } + + it 'returns truthy' do + expect(subject).to eq('true') + end + end + end + + describe '#goto_provider?' do + subject do + goto_provider?(param_form_key:, params:) + end + + context 'params is empty' do + let(:params) { {} } + + it 'returns falsey' do + expect(subject).to be_falsey + end + end + + context 'params has goto_provider set to "true"' do + let(:params) { { goto_provider: 'true' } } + + it 'returns truthy' do + expect(subject).to be_truthy + end + end + + context 'params has param_form_key with goto_provider set to "true"' do + let(:params) { { param_form_key: { goto_provider: 'true' } } } + + it 'returns the value "true"' do + expect(subject).to be_truthy + end + end + + context 'params has param_form_key with goto_provider set to "false"' do + let(:params) { { param_form_key: { goto_provider: 'false' } } } + + it 'returns the value "false"' do + expect(subject).to be_falsey + end + end + end + describe '#back_link_path' do let(:course) { build(:course) }