diff --git a/app/views/users/index.html.erb b/app/views/users/index.html.erb
index dfb6c6929..177b91856 100644
--- a/app/views/users/index.html.erb
+++ b/app/views/users/index.html.erb
@@ -29,8 +29,8 @@
<%= govuk_table do |table| %>
<%= table.caption(size: "s", classes: %w[govuk-!-text-align-left govuk-!-margin-top-4 govuk-!-margin-bottom-4]) do |caption| %>
- <%= @pagy.count %> total users
-
+ Matches <%= @pagy.count %> of <%= User.count%> total users
+
<% if current_user.support? %>
<%= govuk_link_to "Download (CSV)", "/users.csv", type: "text/csv" %>
<% end %>
diff --git a/spec/requests/users_controller_spec.rb b/spec/requests/users_controller_spec.rb
index 8fdaa7b93..07845ac21 100644
--- a/spec/requests/users_controller_spec.rb
+++ b/spec/requests/users_controller_spec.rb
@@ -811,7 +811,7 @@ RSpec.describe UsersController, type: :request do
expect(page).not_to have_content(other_org_user.name)
end
end
- end
+
context "when our search term matches an email" do
let(:search_param) { "other_org@other_example.com" }
@@ -823,8 +823,24 @@ RSpec.describe UsersController, type: :request do
expect(page).to have_content(other_org_user.name)
end
end
+
+
+ context "when our search term matches an email and a name" do
+ let!(:other_user) { FactoryBot.create(:user, organisation: user.organisation, name: "joe", email: "other@example.com") }
+ let!(:other_org_user) { FactoryBot.create(:user, name: "User 4", email: "joe@other_example.com") }
+ let(:search_param) { "joe" }
+
+ it "returns any results including joe" do
+ expect(page).to have_content(other_user.name)
+ expect(page).not_to have_content(inactive_user.name)
+ expect(page).to have_content(other_org_user.name)
+ expect(page).not_to have_content(user.name)
+ end
+ end
end
end
+ end
+
describe "CSV download" do
let(:headers) { { "Accept" => "text/csv" } }