From f721c15d3b1a3da5e329d5dee7b5fd5d2e82b617 Mon Sep 17 00:00:00 2001 From: CatalinVoineag <11318084+CatalinVoineag@users.noreply.github.com> Date: Wed, 10 Jul 2024 15:18:13 +0100 Subject: [PATCH] fix specs --- .../publish/providers_controller.rb | 10 ------- .../publish/about_your_organisation_form.rb | 13 +++++---- app/views/find/courses/show.html.erb | 3 +-- app/views/publish/courses/preview.html.erb | 2 +- .../missing_information_component_spec.rb | 2 +- .../find/search/viewing_a_course_spec.rb | 25 +++++++++++++++-- .../publish/viewing_a_course_preview_spec.rb | 27 ++++++++++++++++--- 7 files changed, 57 insertions(+), 25 deletions(-) diff --git a/app/controllers/publish/providers_controller.rb b/app/controllers/publish/providers_controller.rb index 653d50eed7..83ec521940 100644 --- a/app/controllers/publish/providers_controller.rb +++ b/app/controllers/publish/providers_controller.rb @@ -128,16 +128,6 @@ def provider_params ) end - def provider_params - params - .require(param_form_key) - .except(:goto_preview, :course_code, :goto_provider, :goto_training_with_disabilities) - .permit( - *AboutYourOrganisationForm::FIELDS, - accredited_bodies: %i[provider_name provider_code description] - ) - end - def param_form_key = :publish_about_your_organisation_form def redirect_params diff --git a/app/forms/publish/about_your_organisation_form.rb b/app/forms/publish/about_your_organisation_form.rb index f678eb233e..b499a0c262 100644 --- a/app/forms/publish/about_your_organisation_form.rb +++ b/app/forms/publish/about_your_organisation_form.rb @@ -2,13 +2,16 @@ module Publish class AboutYourOrganisationForm < BaseProviderForm - # validates :train_with_us, presence: { message: 'Enter details about training with you' }, if: :train_with_us_changed? - # validates :train_with_disability, presence: { message: 'Enter details about training with a disability' }, if: :train_with_disability_changed? + include Rails.application.routes.url_helpers - # validates :train_with_us, words_count: { maximum: 250, message: 'Reduce the word count for training with you' } - # validates :train_with_disability, words_count: { maximum: 250, message: 'Reduce the word count for training with disabilities and other needs' } + validates :train_with_us, presence: { message: 'Enter details about training with you' }, if: :train_with_us_changed? + validates :train_with_disability, presence: { message: 'Enter details about training with a disability' }, if: :train_with_disability_changed? + + validates :train_with_us, words_count: { maximum: 250, message: 'Reduce the word count for training with you' } + validates :train_with_disability, words_count: { maximum: 250, message: 'Reduce the word count for training with disabilities and other needs' } + + validate :add_enrichment_errors - # validate :add_enrichment_errors def initialize(model, params: {}, redirect_params: {}, course_code: nil) super(model, params:) @redirect_params = redirect_params diff --git a/app/views/find/courses/show.html.erb b/app/views/find/courses/show.html.erb index d3c21f78a3..8cc136a8a3 100644 --- a/app/views/find/courses/show.html.erb +++ b/app/views/find/courses/show.html.erb @@ -55,10 +55,9 @@ <% if @provider.train_with_disability.present? %>
<%= govuk_link_to( t(".training_with_disabilities_link", provider_name: @course.provider_name), diff --git a/app/views/publish/courses/preview.html.erb b/app/views/publish/courses/preview.html.erb index a9ae228398..7c6ff4356b 100644 --- a/app/views/publish/courses/preview.html.erb +++ b/app/views/publish/courses/preview.html.erb @@ -44,7 +44,7 @@ <%= render Find::Courses::InternationalStudentsComponent::View.new(course:) %>
diff --git a/spec/components/course_preview/missing_information_component_spec.rb b/spec/components/course_preview/missing_information_component_spec.rb index 4ada7a3a53..d3913ee87d 100644 --- a/spec/components/course_preview/missing_information_component_spec.rb +++ b/spec/components/course_preview/missing_information_component_spec.rb @@ -27,7 +27,7 @@ module CoursePreview how_school_placements_work: school_placements_publish_provider_recruitment_cycle_course_path(provider_code, recruitment_cycle_year, course_code, goto_preview: true), train_with_disability: - "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_preview: true)}#train-with-disability", + "#{about_publish_provider_recruitment_cycle_path(provider_code, recruitment_cycle_year, course_code:, goto_training_with_disabilities: true)}#train-with-disability", 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: diff --git a/spec/features/find/search/viewing_a_course_spec.rb b/spec/features/find/search/viewing_a_course_spec.rb index da4b0692f2..565c7b9edf 100644 --- a/spec/features/find/search/viewing_a_course_spec.rb +++ b/spec/features/find/search/viewing_a_course_spec.rb @@ -4,6 +4,7 @@ feature 'Viewing a findable course' do include PublishHelper + include Rails.application.routes.url_helpers before do Timecop.travel(Find::CycleTimetable.mid_cycle) @@ -89,6 +90,15 @@ then_i_should_be_on_the_course_page end + scenario 'user views the training with disabilities page' do + given_there_is_a_findable_course + when_i_visit_the_course_page + when_i_click("Find out about training with disabilities and other needs at #{@course.provider_name}") + then_i_should_be_on_the_training_with_disabilities_page + when_i_click("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_on_the_course_page + end + private def given_there_is_a_findable_course @@ -259,8 +269,8 @@ def then_i_should_see_the_course_information 'Certificate must be print in blue ink' ) - expect(find_course_show_page.train_with_disability).to have_content( - provider.train_with_disability + expect(find_course_show_page).to have_content( + 'Training with disabilities and other needs' ) expect(find_course_show_page.school_placements).to have_no_content('Suspended site with vacancies') @@ -379,4 +389,15 @@ def then_i_should_be_on_the_course_page ).to_s ) end + + def then_i_should_be_on_the_training_with_disabilities_page + expect(find_course_show_page.train_with_disability).to have_content( + provider.train_with_disability + ) + + expect(page).to have_link( + "Contact #{course.provider_name}", + href: find_provider_path(@course.provider_code, @course.course_code) + ) + 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 5f38d94c34..6cc8464c2a 100644 --- a/spec/features/publish/viewing_a_course_preview_spec.rb +++ b/spec/features/publish/viewing_a_course_preview_spec.rb @@ -3,6 +3,7 @@ require 'rails_helper' feature 'Course show', { can_edit_current_and_next_cycles: false } do + include Rails.application.routes.url_helpers context 'bursaries and scholarships is announced' do before do FeatureFlag.activate(:bursaries_and_scholarships_announced) @@ -37,14 +38,17 @@ scenario 'blank training with disabilities and other needs' 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("Find out about training with disabilities and other needs at #{@course.provider_name}") and_i_click_link_or_button('Enter details about training with disabilities and other needs') 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_on_the_training_with_disabilities_page and_i_click_link_or_button('Enter details about training with disabilities and other needs') and_i_submit_a_valid_about_your_organisation - then_i_should_be_back_on_the_preview_page + then_i_should_be_on_the_training_with_disabilities_page then_i_should_see_the_updated_content('test training with disabilities') + and_i_click_link_or_button("Back to #{@course.name} (#{course.course_code})") + then_i_should_be_back_on_the_preview_page end scenario 'blank school placements section' do @@ -239,8 +243,8 @@ def then_i_see_the_course_preview_details 'Financial support from the training provider' ) - expect(publish_course_preview_page.train_with_disability).to have_content( - provider.train_with_disability + expect(publish_course_preview_page).to have_content( + 'Training with disabilities and other needs' ) expect(publish_course_preview_page).to have_content '2:1 or above, or equivalent' @@ -504,4 +508,19 @@ def then_i_should_be_on_the_accrediting_provider_page decorated_course.about_accrediting_provider ) end + + def then_i_should_be_on_the_training_with_disabilities_page + expect(publish_course_preview_page.train_with_disability).to have_content( + provider.train_with_disability + ) + + expect(page).to have_link( + "Contact #{course.provider_name}", + href: provider_publish_provider_recruitment_cycle_course_path( + @course.provider_code, + @course.recruitment_cycle_year, + @course.course_code + ) + ) + end end