Browse Source

Update query message

pull/607/head
baarkerlounger 3 years ago
parent
commit
673a3ec2c7
  1. 2
      app/controllers/organisations_controller.rb
  2. 2
      app/controllers/users_controller.rb
  3. 3
      app/views/users/index.html.erb
  4. 8
      spec/requests/users_controller_spec.rb

2
app/controllers/organisations_controller.rb

@ -19,7 +19,7 @@ class OrganisationsController < ApplicationController
def users def users
@pagy, @users = pagy(filtered_users(@organisation.users)) @pagy, @users = pagy(filtered_users(@organisation.users))
@searched = params["search-field"].present? @searched = params["search-field"].presence
render "users/index" render "users/index"
end end

2
app/controllers/users_controller.rb

@ -11,7 +11,7 @@ class UsersController < ApplicationController
redirect_to users_organisation_path(current_user.organisation) unless current_user.support? redirect_to users_organisation_path(current_user.organisation) unless current_user.support?
@pagy, @users = pagy(filtered_users(User.all)) @pagy, @users = pagy(filtered_users(User.all))
@searched = params["search-field"].present? @searched = params["search-field"].presence
respond_to do |format| respond_to do |format|
format.html format.html

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

@ -14,7 +14,8 @@
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<span class="govuk-!-margin-right-4"> <span class="govuk-!-margin-right-4">
<% if @searched %> <% if @searched %>
Matches <strong><%= @pagy.count %></strong> of <strong><%= User.count %></strong> total users. <% item_label = @pagy.count > 1 ? "users" : "user" %>
<strong><%= @pagy.count %></strong> <%= item_label %> found matching ‘<%= @searched %>’ of <strong><%= User.count %></strong> total users.
<% else %> <% else %>
<strong><%= @pagy.count %></strong> total users. <strong><%= @pagy.count %></strong> total users.
<% end %> <% end %>

8
spec/requests/users_controller_spec.rb

@ -381,7 +381,7 @@ RSpec.describe UsersController, type: :request do
end end
it "updates the table caption" do 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
end end
@ -417,7 +417,7 @@ RSpec.describe UsersController, type: :request do
end end
it "updates the table caption" do 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 end
end end
@ -842,7 +842,7 @@ RSpec.describe UsersController, type: :request do
end end
it "updates the table caption" do 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
end end
@ -881,7 +881,7 @@ RSpec.describe UsersController, type: :request do
end end
it "updates the table caption" do 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 end
end end

Loading…
Cancel
Save