Browse Source

added title showing search results and tests for it

pull/756/head
JG 3 years ago
parent
commit
ea62b1b0bc
  1. 2
      app/views/locations/index.html.erb
  2. 48
      spec/requests/locations_controller_spec.rb

2
app/views/locations/index.html.erb

@ -1,5 +1,5 @@
<% item_label = format_label(@pagy.count, "location") %>
<% title = @scheme.service_name %>
<% title = format_title(@searched, @scheme.service_name, current_user, item_label, @pagy.count, nil) %>
<% content_for :title, title %>
<% content_for :before_content do %>

48
spec/requests/locations_controller_spec.rb

@ -864,6 +864,30 @@ RSpec.describe LocationsController, type: :request do
end
end
end
context "when searching" do
let(:searched_location) { locations.first }
let(:search_param) { searched_location.name }
before do
get "/schemes/#{scheme.id}/locations?search=#{search_param}"
end
it "returns matching results" do
expect(page).to have_content(searched_location.name)
locations[1..].each do |location|
expect(page).not_to have_content(location.name)
end
end
it "updates the table caption" do
expect(page).to have_content("1 location found matching ‘#{search_param}")
end
it "has search in the title" do
expect(page).to have_title("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
end
end
context "when signed in as a support user" do
@ -942,6 +966,30 @@ RSpec.describe LocationsController, type: :request do
end
end
end
context "when searching" do
let(:searched_location) { locations.first }
let(:search_param) { searched_location.name }
before do
get "/schemes/#{scheme.id}/locations?search=#{search_param}"
end
it "returns matching results" do
expect(page).to have_content(searched_location.name)
locations[1..].each do |location|
expect(page).not_to have_content(location.name)
end
end
it "updates the table caption" do
expect(page).to have_content("1 location found matching ‘#{search_param}")
end
it "has search in the title" do
expect(page).to have_title("#{scheme.service_name} (1 location matching ‘#{search_param}’) - Submit social housing lettings and sales data (CORE) - GOV.UK")
end
end
end
end

Loading…
Cancel
Save