Skip to content

Commit

Permalink
Add backwards compatibility with the current (v1) results page
Browse files Browse the repository at this point in the history
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
  • Loading branch information
tomas-stefano committed Dec 16, 2024
1 parent 3bfeab5 commit 05dfb41
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/find/v2/results_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def search_courses_params
:send_courses,
:applications_open,
:further_education,
:funding,
study_types: [],
qualifications: [],
funding: []
Expand Down
11 changes: 11 additions & 0 deletions spec/features/find/v2/results/search_results_enabled_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
11 changes: 11 additions & 0 deletions spec/services/courses_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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] } }

Expand Down

0 comments on commit 05dfb41

Please sign in to comment.