Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CPDNPQ-2095] Increase the results limit to 15 #214

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ GEM
net-smtp (0.5.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.6-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.6-x86_64-linux)
Expand Down Expand Up @@ -364,6 +366,7 @@ GEM
zeitwerk (2.6.16)

PLATFORMS
arm64-darwin-23
x86_64-darwin-20
x86_64-darwin-23
x86_64-linux
Expand Down
4 changes: 3 additions & 1 deletion app/lib/local_authority/search.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class LocalAuthority::Search
RESULT_LIMIT = 15

def initialize(scope, query)
@scope = scope
@query = query
Expand All @@ -12,7 +14,7 @@ def call
if search_polygon
result.where("ST_Intersects(geometry, ?)", search_polygon)
else
result.limit(5)
result.limit(RESULT_LIMIT)
end
end

Expand Down
47 changes: 24 additions & 23 deletions spec/features/happy_path_spec.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
require "rails_helper"

RSpec.feature "Happy path", type: :feature do
before do
LocalAuthority::Importer.new.reload!
Hub::Importer.new.reload!
end

let(:expected_hubs_names) do
["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub"]
end

scenario "Performs search" do
VCR.use_cassette("geocoder") do
visit root_path
expect(page).to have_text("Where do you want to find teaching school hubs?")
fill_in "Where do you want to find teaching school hubs?", with: "Luton"
click_button('Continue')
hubs = all('h2 a').map(&:text)
expect(hubs).to eq(expected_hubs_names)
end
end
end
require "rails_helper"

RSpec.feature "Happy path", type: :feature do
before do
LocalAuthority::Importer.new.reload!
Hub::Importer.new.reload!
end

let(:expected_hubs_names) do
["Chiltern Teaching School Hub", "Chiltern Teaching School Hub", "Alban Teaching School Hub",
"Astra Teaching School Hub, Buckinghamshire", "Cambridgeshire and Peterborough Teaching School Hub"]
end

scenario "Performs search" do
VCR.use_cassette("geocoder") do
visit root_path
expect(page).to have_text("Where do you want to find teaching school hubs?")
fill_in "Where do you want to find teaching school hubs?", with: "Luton"
click_button('Continue')
hubs = all('h2 a').map(&:text)
expect(hubs).to eq(expected_hubs_names)
end
end
end
Loading