Commit 451cb4a7 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '349848-indicate-locked-users-in-admin-users-list-view' into 'master'

Indicate locked users in Admin Area users list

See merge request gitlab-org/gitlab!79160
parents 8fd4e054 d61dc91e
......@@ -101,6 +101,7 @@ module UsersHelper
badges << { text: s_('AdminUsers|Admin'), variant: 'success' } if user.admin?
badges << { text: s_('AdminUsers|External'), variant: 'secondary' } if user.external?
badges << { text: s_("AdminUsers|It's you!"), variant: 'muted' } if current_user == user
badges << { text: s_("AdminUsers|Locked"), variant: 'warning' } if user.access_locked?
end
end
......
......@@ -2819,6 +2819,9 @@ msgstr ""
msgid "AdminUsers|Learn more about %{link_start}banned users.%{link_end}"
msgstr ""
msgid "AdminUsers|Locked"
msgstr ""
msgid "AdminUsers|Log in"
msgstr ""
......
......@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec.describe 'Admin::Users' do
include Spec::Support::Helpers::Features::AdminUsersHelpers
include Spec::Support::Helpers::ModalHelpers
let_it_be(:user, reload: true) { create(:omniauth_user, provider: 'twitter', extern_uid: '123456') }
let_it_be(:current_user) { create(:admin) }
......@@ -294,6 +295,22 @@ RSpec.describe 'Admin::Users' do
end
end
context 'when a user is locked', time_travel_to: '2020-02-25 10:30:45 -0700' do
let_it_be(:locked_user) { create(:user, locked_at: DateTime.parse('2020-02-25 10:30:00 -0700')) }
it "displays `Locked` badge next to user" do
expect(page).to have_content("#{locked_user.name} Locked")
end
it 'allows a user to be unlocked from the `User administration dropdown', :js do
accept_gl_confirm("Unlock user #{locked_user.name}?", button_text: 'Unlock') do
click_action_in_user_dropdown(locked_user.id, 'Unlock')
end
expect(page).not_to have_content("#{locked_user.name} (Locked)")
end
end
describe 'internal users' do
context 'when showing a `Ghost User`' do
let_it_be(:ghost_user) { create(:user, :ghost) }
......
......@@ -122,7 +122,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(blocked_user)
expect(filter_ee_badges(badges)).to eq([text: "Blocked", variant: "danger"])
expect(filter_ee_badges(badges)).to match_array([text: "Blocked", variant: "danger"])
end
end
......@@ -132,7 +132,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(blocked_pending_approval_user)
expect(filter_ee_badges(badges)).to eq([text: 'Pending approval', variant: 'info'])
expect(filter_ee_badges(badges)).to match_array([text: 'Pending approval', variant: 'info'])
end
end
......@@ -142,7 +142,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(banned_user)
expect(filter_ee_badges(badges)).to eq([text: 'Banned', variant: 'danger'])
expect(filter_ee_badges(badges)).to match_array([text: 'Banned', variant: 'danger'])
end
end
......@@ -152,7 +152,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(admin_user)
expect(filter_ee_badges(badges)).to eq([text: "Admin", variant: "success"])
expect(filter_ee_badges(badges)).to match_array([text: "Admin", variant: "success"])
end
end
......@@ -162,7 +162,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(external_user)
expect(filter_ee_badges(badges)).to eq([text: "External", variant: "secondary"])
expect(filter_ee_badges(badges)).to match_array([text: "External", variant: "secondary"])
end
end
......@@ -170,7 +170,7 @@ RSpec.describe UsersHelper do
it 'returns the "It\'s You" badge' do
badges = helper.user_badges_in_admin_section(user)
expect(filter_ee_badges(badges)).to eq([text: "It's you!", variant: "muted"])
expect(filter_ee_badges(badges)).to match_array([text: "It's you!", variant: "muted"])
end
end
......@@ -180,7 +180,7 @@ RSpec.describe UsersHelper do
badges = helper.user_badges_in_admin_section(user)
expect(badges).to eq([
expect(badges).to match_array([
{ text: "Blocked", variant: "danger" },
{ text: "Admin", variant: "success" },
{ text: "External", variant: "secondary" }
......@@ -188,6 +188,16 @@ RSpec.describe UsersHelper do
end
end
context 'with a locked user', time_travel_to: '2020-02-25 10:30:45 -0700' do
it 'returns the "Locked" badge' do
locked_user = create(:user, locked_at: DateTime.parse('2020-02-25 10:30:00 -0700'))
badges = helper.user_badges_in_admin_section(locked_user)
expect(filter_ee_badges(badges)).to match_array([text: "Locked", variant: "warning"])
end
end
context 'get badges for normal user' do
it 'returns no badges' do
user = create(:user)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment