Browse Source

Show deactivated user in the user list

pull/624/head
Kat 3 years ago
parent
commit
9ea6e77fef
  1. 2
      app/controllers/modules/search_filter.rb
  2. 1
      app/models/user.rb
  3. 2
      app/views/users/_user_list.html.erb
  4. 8
      spec/controllers/modules/search_filter_spec.rb
  5. 4
      spec/requests/organisations_controller_spec.rb
  6. 10
      spec/requests/users_controller_spec.rb

2
app/controllers/modules/search_filter.rb

@ -8,6 +8,6 @@ module Modules::SearchFilter
end
def filtered_users(base_collection, search_term = nil)
filtered_collection(base_collection, search_term).filter_by_active.includes(:organisation)
filtered_collection(base_collection, search_term).includes(:organisation)
end
end

1
app/models/user.rb

@ -34,7 +34,6 @@ class User < ApplicationRecord
scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }
scope :search_by_email, ->(email) { where("email ILIKE ?", "%#{email}%") }
scope :filter_by_active, -> { where(active: true) }
scope :search_by, ->(param) { search_by_name(param).or(search_by_email(param)) }
def case_logs

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

@ -47,7 +47,7 @@
) : "" %>
<% end %>
<% row.cell(text: simple_format(org_cell(user), {}, wrapper_tag: "div")) %>
<% row.cell(text: user.last_sign_in_at&.to_formatted_s(:govuk_date)) %>
<% row.cell(text: user.active? ? user.last_sign_in_at&.to_formatted_s(:govuk_date) : "Deactivated") %>
<% end %>
<% end %>
<% end %>

8
spec/controllers/modules/search_filter_spec.rb

@ -40,16 +40,16 @@ RSpec.describe Modules::SearchFilter do
context "when given a search term" do
let(:search_term) { "Blogg" }
it "filters the collection on search term and active users" do
expect(instance.filtered_users(user_list, search_term).count).to eq(1)
it "filters the collection on search term" do
expect(instance.filtered_users(user_list, search_term).count).to eq(2)
end
end
context "when not given a search term" do
let(:search_term) { nil }
it "filters the collection on active users" do
expect(instance.filtered_users(user_list, search_term).count).to eq(6)
it "returns all the users" do
expect(instance.filtered_users(user_list, search_term).count).to eq(7)
end
end
end

4
spec/requests/organisations_controller_spec.rb

@ -134,12 +134,12 @@ RSpec.describe OrganisationsController, type: :request do
it "shows only active users in the current user's organisation" do
expect(page).to have_content(user.name)
expect(page).to have_content(other_user.name)
expect(page).not_to have_content(inactive_user.name)
expect(page).to have_content(inactive_user.name)
expect(page).not_to have_content(other_org_user.name)
end
it "shows the pagination count" do
expect(page).to have_content("2 total users")
expect(page).to have_content("3 total users")
end
end

10
spec/requests/users_controller_spec.rb

@ -900,15 +900,19 @@ RSpec.describe UsersController, type: :request do
get "/users", headers:, params: {}
end
it "shows all active users" do
it "shows all users" do
expect(page).to have_content(user.name)
expect(page).to have_content(other_user.name)
expect(page).not_to have_content(inactive_user.name)
expect(page).to have_content(inactive_user.name)
expect(page).to have_content(other_org_user.name)
end
it "shows last logged in as deactivated for inactive users" do
expect(page).to have_content("Deactivated")
end
it "shows the pagination count" do
expect(page).to have_content("3 total users")
expect(page).to have_content("4 total users")
end
it "shows the download csv link" do

Loading…
Cancel
Save