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 2767accdf0..77e812196d 100644 --- a/app/components/find/courses/about_schools_component/view.html.erb +++ b/app/components/find/courses/about_schools_component/view.html.erb @@ -18,7 +18,7 @@ <% if course.fee_based? %>

- You’ll be placed in schools for most of your course to get classroom experience. You will also spend time at a location where you will study. + You should get 120 days of classroom experience in schools. You will also spend time at a location where you will study.

<% else %>

diff --git a/app/components/find/courses/training_locations/view.html.erb b/app/components/find/courses/training_locations/view.html.erb index e53f9d327c..d26e633a3e 100644 --- a/app/components/find/courses/training_locations/view.html.erb +++ b/app/components/find/courses/training_locations/view.html.erb @@ -4,7 +4,7 @@ <%= row.with_value do %>

<%= potential_placements_text %>

<%= govuk_link_to(t("view_list_of_school_placements"), placements_url) if show_school_placements_link? %> -

Locations can change and are not guaranteed

+

Schools can change and are not guaranteed

<% end %> <% end %> <%= summary_list.with_row do |row| %> diff --git a/app/components/find/courses/training_locations/view.rb b/app/components/find/courses/training_locations/view.rb index 857423cf22..608306f150 100644 --- a/app/components/find/courses/training_locations/view.rb +++ b/app/components/find/courses/training_locations/view.rb @@ -29,7 +29,7 @@ def placements_url def potential_placements_text if course.fee_based? - pluralize(course.sites.size, 'potential placement location') + pluralize(course.sites.size, 'potential placement school') else pluralize(course.sites.size, 'potential employing school') end diff --git a/app/components/find/results/results_component.html.erb b/app/components/find/results/results_component.html.erb index e059700efc..9ea099d764 100644 --- a/app/components/find/results/results_component.html.erb +++ b/app/components/find/results/results_component.html.erb @@ -26,8 +26,7 @@ <%= render Find::Results::SearchResultComponent.new( course:, filtered_by_location: results.location_filter?, - sites_count: results.sites_count(course), - search_params: + results_view: results ) %> <% end %> diff --git a/app/components/find/results/results_component.rb b/app/components/find/results/results_component.rb index 0cb56e4db9..c4943d78dd 100644 --- a/app/components/find/results/results_component.rb +++ b/app/components/find/results/results_component.rb @@ -5,13 +5,12 @@ module Results class ResultsComponent < ViewComponent::Base include ::ViewHelper - attr_reader :results, :courses, :search_params + attr_reader :results, :courses - def initialize(results:, courses:, search_params:) + def initialize(results:, courses:) super @results = results @courses = courses - @search_params = search_params end end end diff --git a/app/components/find/results/search_result_component.html.erb b/app/components/find/results/search_result_component.html.erb index a072608b91..07bdd81c98 100644 --- a/app/components/find/results/search_result_component.html.erb +++ b/app/components/find/results/search_result_component.html.erb @@ -1,16 +1,21 @@
  • <%= govuk_summary_card(classes: ["course-summary-card"], title: course_title_link) do |card| %> <%= card.with_summary_list(actions: false, classes: ["govuk-summary-list--no-border"]) do |summary_list| %> - <% if filtered_by_location? && has_sites? %> - <% summary_list.with_row do |row| %> - <% if course.provider.decorate.website.present? %> + <% if course.provider.decorate.website.present? %> + <% summary_list.with_row do |row| %> <% row.with_key(text: location_label) %> <% row.with_value do %> - <% if course.university_based? %> - <%= render partial: "find/results/university", locals: { course: } %> + <% if has_sites? %> + <% if filtered_by_location? %> + <%= render partial: "find/results/by_location", + locals: { site_distance:, location_name:, school_term:, sites_count: } %> <% else %> - <%= render partial: "find/results/non_university", locals: { course: } %> + <%= render partial: "find/results/by_country_or_provider", + locals: { sites_count:, school_term: } %> <% end %> + + <% else %> + Not listed yet <% end %> <% end %> <% end %> diff --git a/app/components/find/results/search_result_component.rb b/app/components/find/results/search_result_component.rb index a99f13419b..a4db0d41b6 100644 --- a/app/components/find/results/search_result_component.rb +++ b/app/components/find/results/search_result_component.rb @@ -5,16 +5,17 @@ module Results class SearchResultComponent < ViewComponent::Base include ::ViewHelper - attr_reader :course + attr_reader :course, :sites_count delegate :age_range_in_years_and_level, :course_length_with_study_mode, to: :course - def initialize(course:, search_params:, filtered_by_location: false, sites_count: 0) + def initialize(course:, results_view:, filtered_by_location: false) super @course = course.decorate @filtered_by_location = filtered_by_location - @sites_count = sites_count - @search_params = search_params + @sites_count = results_view.sites_count(course) + @results_view = results_view + @search_params = results_view.query_parameters.to_query end def filtered_by_location? @@ -22,20 +23,40 @@ def filtered_by_location? end def has_sites? - @sites_count.positive? + sites_count.positive? end def course_title_link t( '.course_title_html', - course_path: find_course_path(provider_code: course.provider_code, course_code: course.course_code, search_params: @search_params.to_query), + course_path: find_course_path(provider_code: course.provider_code, course_code: course.course_code, search_params: @search_params), provider_name: helpers.smart_quotes(course.provider.provider_name), course_name: course.name_and_code ) end def location_label - t('.location', count: @sites_count) + if course.fee_based? + t('.fee_based.location', count: sites_count) + else + t('.salary_based.location', count: sites_count) + end + end + + def location_name + @results_view.query_parameters['lq'] + end + + def school_term + if course.fee? + 'placement' + else + 'employing' + end + end + + def site_distance + @results_view.site_distance(course) end private diff --git a/app/views/find/results/_by_country_or_provider.html.erb b/app/views/find/results/_by_country_or_provider.html.erb new file mode 100644 index 0000000000..8d20eff214 --- /dev/null +++ b/app/views/find/results/_by_country_or_provider.html.erb @@ -0,0 +1,3 @@ + + <%= sites_count %> potential <%= school_term %> <%= "school".pluralize(sites_count) %> + diff --git a/app/views/find/results/_by_location.html.erb b/app/views/find/results/_by_location.html.erb new file mode 100644 index 0000000000..84a935e5b2 --- /dev/null +++ b/app/views/find/results/_by_location.html.erb @@ -0,0 +1,10 @@ +
    + <%= pluralize(site_distance, "mile") %> from <%= location_name %> +
    + + <% if sites_count == 1 %> + Nearest potential <%= school_term %> school + <% elsif %> + Nearest of <%= sites_count %> potential <%= school_term %> schools + <% end %> + diff --git a/app/views/find/results/_non_university.html.erb b/app/views/find/results/_non_university.html.erb deleted file mode 100644 index 29282127a1..0000000000 --- a/app/views/find/results/_non_university.html.erb +++ /dev/null @@ -1,18 +0,0 @@ -<% number_of_sites = @results_view.sites_count(course) %> -<% nearest_address = @results_view.nearest_address(course) %> -<% nearest_location_name = @results_view.nearest_location_name(course) %> - -<%= "#{pluralize(@results_view.site_distance(course), 'mile')} from you" %> -<% if number_of_sites > 1 %> -
    - (Nearest of <%= number_of_sites %> schools to choose from) -
    -<% end %> - -Location -<% if nearest_location_name != "Main Site" %> - <%= nearest_location_name %>
    -<% end %> -
    - <%= nearest_address %> -
    diff --git a/app/views/find/results/_university.html.erb b/app/views/find/results/_university.html.erb deleted file mode 100644 index a7611051ce..0000000000 --- a/app/views/find/results/_university.html.erb +++ /dev/null @@ -1,24 +0,0 @@ - diff --git a/app/views/find/results/index.html.erb b/app/views/find/results/index.html.erb index 626f09803c..7246fe1e76 100644 --- a/app/views/find/results/index.html.erb +++ b/app/views/find/results/index.html.erb @@ -2,6 +2,5 @@ <%= render Find::Results::ResultsComponent.new( results: @results_view, - courses: @courses, - search_params: @search_params + courses: @courses ) %> diff --git a/config/locales/find.yml b/config/locales/find.yml index cf7fceca23..65aca83186 100644 --- a/config/locales/find.yml +++ b/config/locales/find.yml @@ -193,9 +193,14 @@ en: results: search_result_component: no_degree_required: No degree required - location: - one: Location - other: Nearest location + fee_based: + location: + one: Placement school + other: Placement schools + salary_based: + location: + one: Employing school + other: Employing schools nearest_location: Nearest location fee_or_salary: Fee or salary course_fee: Course fee 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 0c9262308c..645c42ceeb 100644 --- a/spec/components/find/courses/about_schools_component/view_spec.rb +++ b/spec/components/find/courses/about_schools_component/view_spec.rb @@ -60,7 +60,7 @@ result = render_inline(described_class.new(course)) - expect(result.text).to include('You’ll be placed in schools for most of your course to get classroom experience. You will also spend time at a location where you will study.') + expect(result.text).to include('You should get 120 days of classroom experience in schools. You will also spend time at a location where you will study.') end end diff --git a/spec/components/find/courses/training_locations/view_spec.rb b/spec/components/find/courses/training_locations/view_spec.rb index 901a6380e3..1c032402e6 100644 --- a/spec/components/find/courses/training_locations/view_spec.rb +++ b/spec/components/find/courses/training_locations/view_spec.rb @@ -23,7 +23,7 @@ end it 'renders the hint about placements not being guaranteed' do - expect(subject).to have_css('.govuk-hint', text: 'Locations can change and are not guaranteed') + expect(subject).to have_css('.govuk-hint', text: 'Schools can change and are not guaranteed') end end @@ -39,7 +39,7 @@ end it 'renders the hint about placements not being guaranteed' do - expect(subject).to have_css('.govuk-hint', text: 'Locations can change and are not guaranteed') + expect(subject).to have_css('.govuk-hint', text: 'Schools can change and are not guaranteed') end it "renders 'Where you will study' for study sites" do @@ -120,7 +120,7 @@ let(:course) { create(:course, :with_full_time_sites, funding: 'fee', study_sites: [build(:site, :study_site)]) } it 'returns the correct text for one potential placement location' do - expect(component.potential_placements_text).to eq('1 potential placement location') + expect(component.potential_placements_text).to eq('1 potential placement school') end end @@ -136,7 +136,7 @@ let(:course) { create(:course, funding: 'fee', sites: [create(:site), create(:site), create(:site)]) } it 'returns the correct text for multiple placements' do - expect(component.potential_placements_text).to eq('3 potential placement locations') + expect(component.potential_placements_text).to eq('3 potential placement schools') end end end diff --git a/spec/components/find/results/results_component_spec.rb b/spec/components/find/results/results_component_spec.rb index 31c413548a..21c031a4d6 100644 --- a/spec/components/find/results/results_component_spec.rb +++ b/spec/components/find/results/results_component_spec.rb @@ -12,16 +12,6 @@ module Find end context 'when there are no search results' do - let(:search_params) do - { 'age_group' => 'primary', - 'applications_open' => 'true', - 'can_sponsor_visa' => 'false', - 'has_vacancies' => 'true', - 'l' => '2', - 'subjects' => ['00'], - 'visa_status' => 'false' } - end - let(:results_view) do instance_double( Find::ResultsView, @@ -30,8 +20,7 @@ module Find subjects: [], number_of_courses_string: 'No courses', no_results_found?: true, - has_results?: false, - sites_count: 0 + has_results?: false ) end @@ -39,7 +28,7 @@ module Find it 'renders a "No courses found" message when there are no results' do component = render_inline( - described_class.new(results: results_view, courses:, search_params:) + described_class.new(results: results_view, courses:) ) expect(component.text).to include('No courses found') @@ -47,23 +36,13 @@ module Find it 'renders the inset text' do component = render_inline( - described_class.new(results: results_view, courses:, search_params:) + described_class.new(results: results_view, courses:) ) expect(component.text).to include('event near you') end end context 'when there are 10 matching courses' do - let(:search_params) do - { 'age_group' => 'primary', - 'applications_open' => 'true', - 'can_sponsor_visa' => 'false', - 'has_vacancies' => 'true', - 'l' => '2', - 'subjects' => ['00'], - 'visa_status' => 'false' } - end - let(:results_view) do instance_double( Find::ResultsView, @@ -73,30 +52,28 @@ module Find number_of_courses_string: '10 courses', no_results_found?: false, has_results?: true, - location_filter?: false, - sites_count: 2 + location_filter?: false ) end let(:courses) { ::Course.all.page(1) } before do - create_list(:course, 10) + create_list(:course, 10, :with_2_full_time_sites) end it 'renders "10 courses found" and a `SearchResultComponent` for each course' do allow(Results::SearchResultComponent).to receive(:new).and_return(plain: '') component = render_inline( - described_class.new(results: results_view, courses:, search_params:) + described_class.new(results: results_view, courses:) ) courses.each do |course| expect(Results::SearchResultComponent).to have_received(:new).with( course:, - search_params:, - filtered_by_location: false, - sites_count: 2 + results_view:, + filtered_by_location: false ) end @@ -105,15 +82,14 @@ module Find it 'renders the inset text' do component = render_inline( - described_class.new(results: results_view, courses:, search_params:) + described_class.new(results: results_view, courses:) ) courses.each do |course| expect(Results::SearchResultComponent).to have_received(:new).with( course:, - search_params:, - filtered_by_location: false, - sites_count: 2 + results_view:, + filtered_by_location: false ) end expect(component.text).to include('event near you') diff --git a/spec/components/find/results/search_result_component/filtered_by_location_spec.rb b/spec/components/find/results/search_result_component/filtered_by_location_spec.rb new file mode 100644 index 0000000000..9c734ccc8f --- /dev/null +++ b/spec/components/find/results/search_result_component/filtered_by_location_spec.rb @@ -0,0 +1,155 @@ +# frozen_string_literal: true + +require 'rails_helper' + +module Find + describe Results::SearchResultComponent, type: :component do + let(:args) do + search_params = { 'age_group' => 'primary', + 'applications_open' => 'true', + 'c' => 'England', + 'degree_required' => 'show_all_courses', + 'l' => '1', + 'latitude' => '51.5072178', + 'loc' => 'London, UK', + 'longitude' => '-0.1275862', + 'lq' => 'London', + 'page' => '1', + 'can_sponsor_visa' => 'false', + 'filtered_by_location' => 'true', + 'radius' => '1', + 'sortby' => 'distance', + 'has_vacancies' => 'true', + 'subjects[]' => 'G1j', + 'subjects' => ['00'], + 'visa_status' => 'false' } + { filtered_by_location: true, + results_view: ResultsView.new(query_parameters: MatchOldParams.call(search_params)), + course: } + end + + describe 'location row' do + context 'fee based course with no sites' do + let(:course) do + build( + :course, + :fee_type_based, + sites: [], + funding: 'fee' + ) + end + + it 'renders Not listed' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Not listed yet' + ) + end + end + + context 'fee based course with 2 sites' do + let(:course) do + build( + :course, + :fee_type_based, + :with_2_full_time_sites, + funding: 'fee' + ) + end + + it 'renders 2 placement locations' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Placement school', + '9 miles from London', + 'Nearest of 2 potential placement schools' + ) + end + end + + context 'fee based course with 1 site' do + let(:course) do + build( + :course, + :fee_type_based, + :with_full_time_sites, + funding: 'fee' + ) + end + + it 'renders one placement location' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Placement school', + '9 miles from London', + 'Nearest potential placement school' + ) + end + end + + context 'salary based course with no sites' do + let(:course) do + build( + :course, + :salary_type_based, + sites: [], + funding: 'salary' + ) + end + + it 'renders correct message' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Not listed yet' + ) + end + end + + context 'salary based course with 2 sites' do + let(:course) do + build( + :course, + :salary_type_based, + :with_2_full_time_sites, + funding: 'salary' + ) + end + + it 'renders correct message' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Employing school', + '9 miles from London', + 'Nearest of 2 potential employing school' + ) + end + end + + context 'salary based course with 1 site' do + let(:course) do + build( + :course, + :salary_type_based, + :with_full_time_sites, + funding: 'salary' + ) + end + + it 'renders one employing location' do + result = render_inline(described_class.new(**args)) + + expect(result.text).to include( + 'Employing school', + '9 miles from London', + 'Nearest potential employing schoo' + ) + end + end + end + end +end diff --git a/spec/components/find/results/search_result_component_preview.rb b/spec/components/find/results/search_result_component_preview.rb new file mode 100644 index 0000000000..d271413db2 --- /dev/null +++ b/spec/components/find/results/search_result_component_preview.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true + +module Find + module Results + class SearchResultComponentPreview < ViewComponent::Preview + def by_location_with_2_sites + course = FactoryBot.build_stubbed(:course) + mock_results_view_class = Struct.new(:one) do + def sites_count(*) = 2 + def query_parameters = { 'lq' => 'London' } + def site_distance(*) = 2 + end + results_view = mock_results_view_class.new(1) + render(SearchResultComponent.new( + filtered_by_location: true, + results_view:, + course: + )) + end + + def by_location_with_1_site + course = FactoryBot.build_stubbed(:course) + mock_results_view_class = Struct.new(:one) do + def sites_count(*) = 1 + def query_parameters = { 'lq' => 'London' } + def site_distance(*) = 2.3 + end + results_view = mock_results_view_class.new(1) + render(SearchResultComponent.new( + filtered_by_location: true, + results_view:, + course: + )) + end + + def by_country_with_1_site + course = FactoryBot.build_stubbed(:course) + mock_results_view_class = Struct.new(:one) do + def sites_count(*) = 1 + def query_parameters = {} + end + results_view = mock_results_view_class.new(1) + render(SearchResultComponent.new( + filtered_by_location: false, + results_view:, + course: + )) + end + + def by_country_with_2_sites + course = FactoryBot.build_stubbed(:course) + mock_results_view_class = Struct.new(:one) do + def sites_count(*) = 2 + def query_parameters = {} + end + results_view = mock_results_view_class.new(1) + render(SearchResultComponent.new( + filtered_by_location: false, + results_view:, + course: + )) + end + end + end +end diff --git a/spec/components/find/results/search_result_component_spec.rb b/spec/components/find/results/search_result_component_spec.rb index 9f86cf61ae..c95b40e50f 100644 --- a/spec/components/find/results/search_result_component_spec.rb +++ b/spec/components/find/results/search_result_component_spec.rb @@ -4,18 +4,18 @@ module Find describe Results::SearchResultComponent, type: :component do - let(:search_params) do - { 'age_group' => 'primary', - 'applications_open' => 'true', - 'can_sponsor_visa' => 'false', - 'has_vacancies' => 'true', - 'l' => '2', - 'subjects' => ['00'], - 'visa_status' => 'false' } + let(:results_view) do + ResultsView.new(query_parameters: { 'age_group' => 'primary', + 'applications_open' => 'true', + 'can_sponsor_visa' => 'false', + 'has_vacancies' => 'true', + 'l' => '2', + 'subjects' => ['00'], + 'visa_status' => 'false' }) end context 'delegations' do - subject { described_class.new(course: build(:course), search_params:) } + subject { described_class.new(course: build(:course), results_view:) } it { is_expected.to delegate_method(:age_range_in_years_and_level).to(:course) } it { is_expected.to delegate_method(:course_length_with_study_mode).to(:course) } @@ -27,7 +27,7 @@ module Find :course, degree_grade: :two_one ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include( '2:1 bachelor’s degree', @@ -44,7 +44,7 @@ module Find can_sponsor_student_visa: false, can_sponsor_skilled_worker_visa: true ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include( 'Skilled Worker visas can be sponsored' @@ -60,7 +60,7 @@ module Find can_sponsor_student_visa: false, can_sponsor_skilled_worker_visa: true ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include( 'Visas cannot be sponsored' @@ -71,7 +71,7 @@ module Find context 'when the provider specifies student visa sponsorship' do it 'renders correct message when only one kind of visa is sponsored' do course = build(:course, :can_sponsor_student_visa, :fee_type_based) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include( 'Student visas can be sponsored' @@ -84,7 +84,7 @@ module Find can_sponsor_student_visa: false, can_sponsor_skilled_worker_visa: false ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include( 'Visas cannot be sponsored' @@ -98,7 +98,7 @@ module Find :course, accrediting_provider: build(:provider, :accredited_provider, provider_name: 'ACME SCITT A1') ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include('QTS ratified by ACME SCITT A1') end @@ -110,7 +110,7 @@ module Find :course, accrediting_provider: nil ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).not_to include('QTS ratified by') end @@ -120,7 +120,7 @@ module Find it 'renders the uk fees' do course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250)]).decorate - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include('£9,250 for UK citizens') expect(result.text).to include('Course fee') end @@ -130,7 +130,7 @@ module Find it 'renders the international fees' do course = create(:course, enrichments: [create(:course_enrichment, fee_international: 14_000)]).decorate - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include('£14,000 for Non-UK citizens') end end @@ -139,7 +139,7 @@ module Find it 'renders the uk fees and not the internation fee label' do course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: 9250, fee_international: nil)]).decorate - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).to include('£9,250 for UK citizens') expect(result.text).not_to include('Non-UK citizens') @@ -150,7 +150,7 @@ module Find it 'renders the international fees but not the uk fee label' do course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: 14_000)]).decorate - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).not_to include('for UK citizens') expect(result.text).to include('£14,000 for Non-UK citizens') @@ -161,7 +161,7 @@ module Find it 'does not render the row' do course = create(:course, enrichments: [create(:course_enrichment, fee_uk_eu: nil, fee_international: nil)]).decorate - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result.text).not_to include('for UK citizens') expect(result.text).not_to include('£14,000 for Non-UK citizens') @@ -175,7 +175,7 @@ module Find level: 'secondary', age_range_in_years: '11_to_16') - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result).to have_text('Age range 11 to 16 - secondary', normalize_ws: true) end @@ -189,10 +189,40 @@ module Find study_mode: 'full_time' ) - result = render_inline(described_class.new(course:, search_params:)) + result = render_inline(described_class.new(course:, results_view:)) expect(result).to have_text('Course length 1 year - full time', normalize_ws: true) end end + + context 'school placements (search by country or provider)' do + context 'fee_based with 1 school' do + it 'renders the school placement text' do + course = create( + :course, + :with_full_time_sites + ) + + result = render_inline(described_class.new(course:, results_view:)) + + expect(result).to have_text('Employing school') + expect(result).to have_text('1 potential employing school') + end + end + + context 'fee_based with 2 schools' do + it 'renders the school placement text' do + course = create( + :course, + :with_2_full_time_sites + ) + + result = render_inline(described_class.new(course:, results_view:)) + + expect(result).to have_text('Employing schools') + expect(result).to have_text('2 potential employing schools') + end + end + end end end diff --git a/spec/factories/courses.rb b/spec/factories/courses.rb index d73f74b3b5..e1e3a569da 100644 --- a/spec/factories/courses.rb +++ b/spec/factories/courses.rb @@ -228,6 +228,15 @@ site_statuses { [build(:site_status, :findable, vac_status: :full_time_vacancies, site: build(:site, latitude: 51.5079, longitude: 0.0877, address1: '1 Foo Street', postcode: 'BN1 1AA'))] } end + trait :with_2_full_time_sites do + site_statuses do + [ + build(:site_status, :findable, vac_status: :full_time_vacancies, site: build(:site, latitude: 51.5079, longitude: 0.0877, address1: '1 Foo Street', postcode: 'BN1 1AA')), + build(:site_status, :findable, vac_status: :full_time_vacancies, site: build(:site, latitude: 51.5079, longitude: 0.0897, address1: '1 Bar Street', postcode: 'BN1 1DD')) + ] + end + end + trait :draft_enrichment do enrichments { [build(:course_enrichment, :initial_draft, course: nil)] } end