From 05dfb411d9410c67b226363c5dd45b00199a3da7 Mon Sep 17 00:00:00 2001 From: Tomas D'Stefano Date: Mon, 16 Dec 2024 11:22:12 +0000 Subject: [PATCH] Add backwards compatibility with the current (v1) results page On the live (v1) results page there are no fee and apprenticeship filters, only salary and these is treated as a string "salary". We want to add a collection now, so adding this compatibility to make work --- app/controllers/find/v2/results_controller.rb | 1 + .../find/v2/results/search_results_enabled_spec.rb | 11 +++++++++++ spec/services/courses_query_spec.rb | 11 +++++++++++ 3 files changed, 23 insertions(+) diff --git a/app/controllers/find/v2/results_controller.rb b/app/controllers/find/v2/results_controller.rb index d0689ca01d..49830e043d 100644 --- a/app/controllers/find/v2/results_controller.rb +++ b/app/controllers/find/v2/results_controller.rb @@ -21,6 +21,7 @@ def search_courses_params :send_courses, :applications_open, :further_education, + :funding, study_types: [], qualifications: [], funding: [] diff --git a/spec/features/find/v2/results/search_results_enabled_spec.rb b/spec/features/find/v2/results/search_results_enabled_spec.rb index 42181b778f..1b440d4339 100644 --- a/spec/features/find/v2/results/search_results_enabled_spec.rb +++ b/spec/features/find/v2/results/search_results_enabled_spec.rb @@ -110,6 +110,13 @@ and_i_see_that_there_are_two_courses_found end + scenario 'when I use the old funding parameter' do + when_i_visit_the_find_results_page_using_old_salary_parameter + then_i_see_only_salaried_courses + and_the_salary_filter_is_checked + and_i_see_that_there_is_one_course_found + end + scenario 'when I filter by apprenticeship' do when_i_visit_the_find_results_page and_i_filter_by_apprenticeship_courses @@ -191,6 +198,10 @@ def when_i_visit_the_find_results_page visit find_v2_results_path end + def when_i_visit_the_find_results_page_using_old_salary_parameter + visit(find_v2_results_path(funding: 'salary')) + end + def and_i_filter_by_courses_that_sponsor_visa check 'Only show courses with visa sponsorship' and_i_apply_the_filters diff --git a/spec/services/courses_query_spec.rb b/spec/services/courses_query_spec.rb index f73fb55e68..db5e2f6577 100644 --- a/spec/services/courses_query_spec.rb +++ b/spec/services/courses_query_spec.rb @@ -241,6 +241,17 @@ end end + context 'when filter by salary in the old search parameter' do + let(:params) { { funding: 'salary' } } + + it 'returns courses with salary' do + expect(results).to match_collection( + [salaried_course], + attribute_names: %w[funding] + ) + end + end + context 'when filter by two funding types' do let(:params) { { funding: %w[fee salary] } }