Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions app/views/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@
<p><%= govuk_link_to t('users.index.download_all'), download_users_path, no_visited_state: true %></p>
<% end %>

<p class="govuk-body">
<% if @pagy.pages > 1 %>
<%= t("users.index.showing_count", from: @pagy.from, to: @pagy.to, count: @pagy.count) %>
<% else %>
<%= t("users.index.user_count", count: @pagy.count) %>
<% end %>
</p>

<%= govuk_pagination(pagy: @pagy) %>

<%= render ScrollingWrapperComponent::View.new(aria_label: t("users.index.wrapper_aria_label")) do |table| %>
Expand Down
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2348,6 +2348,7 @@ en:
submit: Filter
name_blank: No name set
organisation_blank: No organisation set
showing_count: Showing %{from} to %{to} of %{count} users
table_headings:
access: Access
act_as_user: Act as user
Expand All @@ -2357,6 +2358,9 @@ en:
role: Role
signon_organisation: Signon organisation slug
title: Users
user_count:
one: Showing 1 user
other: Showing %{count} users
wrapper_aria_label: Users
roles:
all: All roles
Expand Down
14 changes: 14 additions & 0 deletions spec/views/users/index.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
end
let(:filter_input) { Users::FilterInput.new }
let(:filtered_download_path) { Faker::Internet.url }
let(:pagy) { Pagy.new(count: users.size, page: 1, limit: 50) }

before do
allow(Settings).to receive(:act_as_user_enabled).and_return(act_as_user_enabled)
Expand All @@ -20,6 +21,7 @@
assign(:users, users)
assign(:filter_input, filter_input)
assign(:filtered_download_path, filtered_download_path)
assign(:pagy, pagy)
render template: "users/index"
end

Expand All @@ -31,6 +33,18 @@
expect(rendered).to have_css(".app-scrolling-wrapper > table")
end

it "contains the total number of users" do
expect(rendered).to have_css("p", text: "Showing 3 users")
end

context "when the users span multiple pages" do
let(:pagy) { Pagy.new(count: 120, page: 1, limit: 50) }

it "shows how many users are on this page out of the total" do
expect(rendered).to have_css("p", text: "Showing 1 to 50 of 120 users")
end
end

it "contains the user's name" do
expect(rendered).to have_text(users.first.name)
end
Expand Down