diff --git a/app/controllers/admin/poll/booths_controller.rb b/app/controllers/admin/poll/booths_controller.rb
index 7f3ad32aa..c27a65694 100644
--- a/app/controllers/admin/poll/booths_controller.rb
+++ b/app/controllers/admin/poll/booths_controller.rb
@@ -2,7 +2,7 @@ class Admin::Poll::BoothsController < Admin::Poll::BaseController
load_and_authorize_resource class: "Poll::Booth"
def index
- @booths = @booths.search params[:search].strip if params[:search]
+ @booths = @booths.search params[:search] if params[:search]
@booths = @booths.order(name: :asc).page(params[:page])
end
diff --git a/app/views/admin/poll/booths/index.html.erb b/app/views/admin/poll/booths/index.html.erb
index add01ee0d..9a7e38247 100644
--- a/app/views/admin/poll/booths/index.html.erb
+++ b/app/views/admin/poll/booths/index.html.erb
@@ -10,9 +10,9 @@
<% end %>
-<% if @booths.any? %>
- <%= render "/admin/shared/booth_search", url: admin_booths_path %>
+<%= render "/admin/shared/booth_search", url: admin_booths_path %>
+<% if @booths.any? %>
<%= page_entries_info @booths %>
diff --git a/app/views/admin/shared/_booth_search.html.erb b/app/views/admin/shared/_booth_search.html.erb
index 56bae3125..eb22940db 100644
--- a/app/views/admin/shared/_booth_search.html.erb
+++ b/app/views/admin/shared/_booth_search.html.erb
@@ -1,9 +1,9 @@
<%= form_for(Poll::Booth.new, url: url, as: :booth, method: :get) do |f| %>
diff --git a/spec/features/admin/poll/booths_spec.rb b/spec/features/admin/poll/booths_spec.rb
index c49a34b6b..e81f4e539 100644
--- a/spec/features/admin/poll/booths_spec.rb
+++ b/spec/features/admin/poll/booths_spec.rb
@@ -123,4 +123,22 @@ describe "Admin booths" do
click_link "Go back"
expect(page).to have_current_path(available_admin_booths_path)
end
+
+ scenario "Search" do
+ booth = create(:poll_booth)
+
+ visit admin_booths_path
+
+ fill_in "search", with: booth.name
+ click_button "Search"
+ expect(page).to have_css(".booth", count: 1)
+
+ fill_in "search", with: booth.location
+ click_button "Search"
+ expect(page).to have_css(".booth", count: 1)
+
+ fill_in "search", with: "Wrong search criteria"
+ click_button "Search"
+ expect(page).to have_content "There are no active booths for any upcoming poll."
+ end
end
diff --git a/spec/features/admin/poll/shifts_spec.rb b/spec/features/admin/poll/shifts_spec.rb
index f10ce64d5..bbde7be25 100644
--- a/spec/features/admin/poll/shifts_spec.rb
+++ b/spec/features/admin/poll/shifts_spec.rb
@@ -48,7 +48,7 @@ describe "Admin shifts" do
click_link "Manage shifts"
end
- expect(page).to have_content "git This booth has no shifts"
+ expect(page).to have_content "This booth has no shifts"
fill_in "search", with: officer.email
click_button "Search"