Browse Source

WIP Commit - added test for if search term matches a name and an email address simultaneously. Also changed search result caption for organisations to display "Matches X of Y users"

pull/600/head
Ted 3 years ago committed by baarkerlounger
parent
commit
d5c96424c0
  1. 2
      app/views/users/index.html.erb
  2. 18
      spec/requests/users_controller_spec.rb

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

@ -29,7 +29,7 @@
<%= govuk_table do |table| %>
<%= table.caption(size: "s", classes: %w[govuk-!-text-align-left govuk-!-margin-top-4 govuk-!-margin-bottom-4]) do |caption| %>
<span class="govuk-!-margin-right-4">
<strong><%= @pagy.count %></strong><span style="font-weight: normal"> total users</span>
<strong><span style="font-weight: normal"> Matches </span><%= @pagy.count %><span style="font-weight: normal"> of </span><%= User.count%> <span style="font-weight: normal"> total users</strong> </span>
</span>
<% if current_user.support? %>
<%= govuk_link_to "Download (CSV)", "/users.csv", type: "text/csv" %>

18
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" } }

Loading…
Cancel
Save