diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 17d3b8a3f..40f49ea9b 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -19,7 +19,7 @@ class OrganisationsController < ApplicationController def users @pagy, @users = pagy(filtered_users(@organisation.users)) - @searched = params["search-field"].present? + @searched = params["search-field"].presence render "users/index" end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 8e58f7396..102e9b464 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -11,7 +11,7 @@ class UsersController < ApplicationController redirect_to users_organisation_path(current_user.organisation) unless current_user.support? @pagy, @users = pagy(filtered_users(User.all)) - @searched = params["search-field"].present? + @searched = params["search-field"].presence respond_to do |format| format.html diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb index e9bd62065..029b2cbec 100644 --- a/app/views/users/index.html.erb +++ b/app/views/users/index.html.erb @@ -14,7 +14,8 @@ <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> <% if @searched %> - Matches <%= @pagy.count %> of <%= User.count %> total users. + <% item_label = @pagy.count > 1 ? "users" : "user" %> + <%= @pagy.count %> <%= item_label %> found matching ‘<%= @searched %>’ of <%= User.count %> total users. <% else %> <%= @pagy.count %> total users. <% end %> diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb index 10821961c..70434a046 100644 --- a/spec/requests/users_controller_spec.rb +++ b/spec/requests/users_controller_spec.rb @@ -381,7 +381,7 @@ RSpec.describe UsersController, type: :request do end it "updates the table caption" do - expect(page).to have_content("Matches 1 of 5 total users.") + expect(page).to have_content("1 user found matching ‘filter’ of 5 total users.") end end @@ -417,7 +417,7 @@ RSpec.describe UsersController, type: :request do end it "updates the table caption" do - expect(page).to have_content("Matches 2 of 5 total users.") + expect(page).to have_content("2 users found matching ‘joe’ of 5 total users.") end end end @@ -842,7 +842,7 @@ RSpec.describe UsersController, type: :request do end it "updates the table caption" do - expect(page).to have_content("Matches 1 of 4 total users.") + expect(page).to have_content("1 user found matching ‘Danny’ of 4 total users.") end end @@ -881,7 +881,7 @@ RSpec.describe UsersController, type: :request do end it "updates the table caption" do - expect(page).to have_content("Matches 2 of 4 total users.") + expect(page).to have_content("2 users found matching ‘joe’ of 4 total users.") end end end