Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
12e3dfbe
Commit
12e3dfbe
authored
Jun 09, 2021
by
Jiaan Louw
Committed by
Albert Salim
Jun 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove vue_admin_users feature flag [RUN ALL RSPEC] [RUN AS-IF-FOSS]
parent
f2d63afe
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
345 additions
and
493 deletions
+345
-493
app/assets/javascripts/admin/users/components/users_table.vue
...assets/javascripts/admin/users/components/users_table.vue
+1
-0
app/views/admin/users/_user.html.haml
app/views/admin/users/_user.html.haml
+0
-72
app/views/admin/users/_users.html.haml
app/views/admin/users/_users.html.haml
+3
-14
config/feature_flags/development/vue_admin_users.yml
config/feature_flags/development/vue_admin_users.yml
+0
-8
ee/spec/features/admin/admin_users_spec.rb
ee/spec/features/admin/admin_users_spec.rb
+115
-123
scripts/verify-tff-mapping
scripts/verify-tff-mapping
+2
-2
spec/features/admin/users/user_spec.rb
spec/features/admin/users/user_spec.rb
+11
-19
spec/features/admin/users/users_spec.rb
spec/features/admin/users/users_spec.rb
+213
-204
spec/views/admin/users/_user.html.haml_spec.rb
spec/views/admin/users/_user.html.haml_spec.rb
+0
-51
No files found.
app/assets/javascripts/admin/users/components/users_table.vue
View file @
12e3dfbe
...
@@ -107,6 +107,7 @@ export default {
...
@@ -107,6 +107,7 @@ export default {
:items=
"users"
:items=
"users"
:fields=
"$options.fields"
:fields=
"$options.fields"
:empty-text=
"s__('AdminUsers|No users found')"
:empty-text=
"s__('AdminUsers|No users found')"
data-qa-selector=
"user_row_content"
show-empty
show-empty
stacked=
"md"
stacked=
"md"
:tbody-tr-attr=
"
{ 'data-qa-selector': 'user_row_content' }"
:tbody-tr-attr=
"
{ 'data-qa-selector': 'user_row_content' }"
...
...
app/views/admin/users/_user.html.haml
deleted
100644 → 0
View file @
f2d63afe
.gl-responsive-table-row
{
role:
'row'
,
data:
{
qa_selector:
'user_row_content'
}
}
.table-section.section-40
.table-mobile-header
{
role:
'rowheader'
}
=
_
(
'Name'
)
.table-mobile-content
=
render
'user_detail'
,
user:
user
.table-section.section-10
.table-mobile-header
{
role:
'rowheader'
}
=
_
(
'Projects'
)
.table-mobile-content.gl-str-truncated
{
data:
{
testid:
"user-project-count-#{user.id}"
}
}
=
user
.
authorized_projects
.
length
.table-section.section-15
.table-mobile-header
{
role:
'rowheader'
}
=
_
(
'Created on'
)
.table-mobile-content
=
l
(
user
.
created_at
.
to_date
,
format: :admin
)
.table-section.section-15
.table-mobile-header
{
role:
'rowheader'
}
=
_
(
'Last activity'
)
.table-mobile-content
=
user
.
last_activity_on
.
nil?
?
_
(
'Never'
)
:
l
(
user
.
last_activity_on
,
format: :admin
)
-
unless
user
.
internal?
.table-section.section-20.table-button-footer
.table-action-buttons
{
data:
{
testid:
"user-actions-#{user.id}"
}
}
=
link_to
_
(
'Edit'
),
edit_admin_user_path
(
user
),
class:
'btn gl-button btn-default'
-
unless
user
==
current_user
%button
.dropdown-new.btn.gl-button.btn-default
{
type:
'button'
,
data:
{
testid:
"dropdown-toggle"
,
toggle:
'dropdown'
}
}
=
sprite_icon
(
'settings'
)
=
sprite_icon
(
'chevron-down'
)
%ul
.dropdown-menu.dropdown-menu-right
%li
.dropdown-header
=
_
(
'Settings'
)
%li
-
if
user
.
ldap_blocked?
%span
.small
=
s_
(
'AdminUsers|Cannot unblock LDAP blocked users'
)
-
elsif
user
.
blocked?
-
if
user
.
blocked_pending_approval?
=
link_to
s_
(
'AdminUsers|Approve'
),
approve_admin_user_path
(
user
),
method: :put
=
link_to
s_
(
'AdminUsers|Reject'
),
reject_admin_user_path
(
user
),
method: :delete
-
else
%button
.gl-button.btn.btn-default-tertiary.js-confirm-modal-button
{
data:
user_unblock_data
(
user
)
}
=
s_
(
'AdminUsers|Unblock'
)
-
else
%button
.gl-button.btn.btn-default-tertiary.js-confirm-modal-button
{
data:
user_block_data
(
user
,
user_block_effects
)
}
=
s_
(
'AdminUsers|Block'
)
-
if
user
.
can_be_deactivated?
%li
%button
.gl-button.btn.btn-default-tertiary.js-confirm-modal-button
{
data:
user_deactivation_data
(
user
,
user_deactivation_effects
)
}
=
s_
(
'AdminUsers|Deactivate'
)
-
elsif
user
.
deactivated?
%li
%button
.gl-button.btn.btn-default-tertiary.js-confirm-modal-button
{
data:
user_activation_data
(
user
)
}
=
s_
(
'AdminUsers|Activate'
)
-
if
user
.
access_locked?
%li
=
link_to
_
(
'Unlock'
),
unlock_admin_user_path
(
user
),
method: :put
,
data:
{
confirm:
_
(
'Are you sure?'
)
}
-
if
can?
(
current_user
,
:destroy_user
,
user
)
&&
!
user
.
blocked_pending_approval?
%li
.divider
-
if
user
.
can_be_removed?
%li
%button
.js-delete-user-modal-button.gl-button.btn.btn-danger-tertiary
{
data:
{
'gl-modal-action'
:
'delete'
,
delete_user_url:
admin_user_path
(
user
),
block_user_url:
block_admin_user_path
(
user
),
username:
sanitize_name
(
user
.
name
)
}
}
=
s_
(
'AdminUsers|Delete user'
)
%li
%button
.js-delete-user-modal-button.gl-button.btn.btn-danger-tertiary
{
data:
{
'gl-modal-action'
:
'delete-with-contributions'
,
delete_user_url:
admin_user_path
(
user
,
hard_delete:
true
),
block_user_url:
block_admin_user_path
(
user
),
username:
sanitize_name
(
user
.
name
)
}
}
=
s_
(
'AdminUsers|Delete user and contributions'
)
app/views/admin/users/_users.html.haml
View file @
12e3dfbe
...
@@ -73,20 +73,9 @@
...
@@ -73,20 +73,9 @@
=
link_to
admin_users_path
(
sort:
value
,
filter:
params
[
:filter
],
search_query:
params
[
:search_query
])
do
=
link_to
admin_users_path
(
sort:
value
,
filter:
params
[
:filter
],
search_query:
params
[
:search_query
])
do
=
title
=
title
-
if
Feature
.
enabled?
(
:vue_admin_users
,
default_enabled: :yaml
)
#js-admin-users-app
{
data:
admin_users_data_attributes
(
@users
)
}
#js-admin-users-app
{
data:
admin_users_data_attributes
(
@users
)
}
.gl-spinner-container.gl-my-7
.gl-spinner-container.gl-my-7
%span
.gl-vertical-align-bottom.gl-spinner.gl-spinner-dark.gl-spinner-lg
{
aria:
{
label:
_
(
'Loading'
)
}
}
%span
.gl-vertical-align-bottom.gl-spinner.gl-spinner-dark.gl-spinner-lg
{
aria:
{
label:
_
(
'Loading'
)
}
}
-
elsif
@users
.
empty?
.nothing-here-block.border-top-0
=
s_
(
'AdminUsers|No users found'
)
-
else
.table-holder
.thead-white.text-nowrap.gl-responsive-table-row.table-row-header
{
role:
'row'
}
-
user_table_headers
.
each
do
|
header
|
.table-section
{
class:
header
[
:section_class_name
],
role:
'rowheader'
}=
header
[
:header_text
]
=
render
partial:
'admin/users/user'
,
collection:
@users
=
paginate_collection
@users
=
paginate_collection
@users
...
...
config/feature_flags/development/vue_admin_users.yml
deleted
100644 → 0
View file @
f2d63afe
---
name
:
vue_admin_users
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/48922
rollout_issue_url
:
https://gitlab.com/gitlab-org/gitlab/-/issues/290737
milestone
:
'
13.7'
type
:
development
group
:
group::compliance
default_enabled
:
true
ee/spec/features/admin/admin_users_spec.rb
View file @
12e3dfbe
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
require
'spec_helper'
require
'spec_helper'
RSpec
.
describe
"Admin::Users"
do
RSpec
.
describe
"Admin::Users"
,
:js
do
let_it_be
(
:user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
let_it_be
(
:user
)
{
create
(
:omniauth_user
,
provider:
'twitter'
,
extern_uid:
'123456'
)
}
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
let_it_be
(
:current_user
)
{
create
(
:admin
)
}
...
@@ -11,171 +11,163 @@ RSpec.describe "Admin::Users" do
...
@@ -11,171 +11,163 @@ RSpec.describe "Admin::Users" do
gitlab_enable_admin_mode_sign_in
(
current_user
)
gitlab_enable_admin_mode_sign_in
(
current_user
)
end
end
[
true
,
false
].
each
do
|
vue_admin_users
|
describe
'GET /admin/users'
do
context
"with vue_admin_users feature flag set to
#{
vue_admin_users
}
"
,
js:
vue_admin_users
do
describe
'send emails to users'
do
before
do
context
'when `send_emails_from_admin_area` feature is enabled'
do
stub_feature_flags
(
vue_admin_users:
vue_admin_users
)
before
do
end
stub_licensed_features
(
send_emails_from_admin_area:
true
)
end
describe
'GET /admin/users'
do
describe
'send emails to users'
do
context
'when `send_emails_from_admin_area` feature is enabled'
do
before
do
stub_licensed_features
(
send_emails_from_admin_area:
true
)
end
it
"shows the 'Send email to users' link"
do
it
"shows the 'Send email to users' link"
do
visit
admin_users_path
visit
admin_users_path
expect
(
page
).
to
have_link
(
href:
admin_email_path
)
expect
(
page
).
to
have_link
(
href:
admin_email_path
)
end
end
end
end
context
'when `send_emails_from_admin_area` feature is disabled'
do
context
'when `send_emails_from_admin_area` feature is disabled'
do
before
do
before
do
stub_licensed_features
(
send_emails_from_admin_area:
false
)
stub_licensed_features
(
send_emails_from_admin_area:
false
)
end
end
it
"does not show the 'Send email to users' link"
do
it
"does not show the 'Send email to users' link"
do
visit
admin_users_path
visit
admin_users_path
expect
(
page
).
not_to
have_link
(
href:
admin_email_path
)
expect
(
page
).
not_to
have_link
(
href:
admin_email_path
)
end
end
end
end
end
end
describe
'user permission export'
do
describe
'user permission export'
do
context
'when `export_user_permissions` feature is available'
do
context
'when `export_user_permissions` feature is available'
do
before
do
before
do
stub_licensed_features
(
export_user_permissions:
true
)
stub_licensed_features
(
export_user_permissions:
true
)
end
end
it
"shows the 'Export Permissions' link"
do
it
"shows the 'Export Permissions' link"
do
visit
admin_users_path
visit
admin_users_path
expect
(
page
).
to
have_link
(
href:
admin_user_permission_exports_path
(
format: :csv
))
expect
(
page
).
to
have_link
(
href:
admin_user_permission_exports_path
(
format: :csv
))
end
end
end
end
context
'when `export_user_permissions` feature is disabled'
do
context
'when `export_user_permissions` feature is disabled'
do
before
do
before
do
stub_licensed_features
(
export_user_permissions:
false
)
stub_licensed_features
(
export_user_permissions:
false
)
end
end
it
"does not show the 'Export Permissions' link"
do
it
"does not show the 'Export Permissions' link"
do
visit
admin_users_path
visit
admin_users_path
expect
(
page
).
not_to
have_link
(
href:
admin_user_permission_exports_path
(
format: :csv
))
expect
(
page
).
not_to
have_link
(
href:
admin_user_permission_exports_path
(
format: :csv
))
end
end
end
end
end
end
end
end
describe
"GET /admin/users/:id"
do
describe
"GET /admin/users/:id"
do
describe
'Shared runners quota status'
do
describe
'Shared runners quota status'
do
before
do
before
do
user
.
namespace
.
update!
(
shared_runners_minutes_limit:
500
)
user
.
namespace
.
update!
(
shared_runners_minutes_limit:
500
)
end
end
context
'with projects with shared runners enabled'
do
context
'with projects with shared runners enabled'
do
before
do
before
do
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
end
end
it
'shows quota'
do
it
'shows quota'
do
visit
admin_users_path
visit
admin_users_path
click_link
user
.
name
click_link
user
.
name
expect
(
page
).
to
have_content
(
'Pipeline minutes quota: 0 / 500'
)
expect
(
page
).
to
have_content
(
'Pipeline minutes quota: 0 / 500'
)
end
end
end
end
context
'without projects with shared runners enabled'
do
context
'without projects with shared runners enabled'
do
before
do
before
do
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
false
)
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
false
)
end
end
it
'does not show quota'
do
it
'does not show quota'
do
visit
admin_users_path
visit
admin_users_path
click_link
user
.
name
click_link
user
.
name
expect
(
page
).
not_to
have_content
(
'Pipeline minutes quota:'
)
expect
(
page
).
not_to
have_content
(
'Pipeline minutes quota:'
)
end
end
end
end
end
end
end
end
describe
"GET /admin/users/:id/edit"
do
describe
"GET /admin/users/:id/edit"
do
describe
"Update user account type"
do
describe
"Update user account type"
do
before
do
before
do
visit_edit_user
(
user
.
id
)
visit_edit_user
(
user
.
id
)
allow_any_instance_of
(
AuditorUserHelper
).
to
receive
(
:license_allows_auditor_user?
).
and_return
(
true
)
allow_any_instance_of
(
AuditorUserHelper
).
to
receive
(
:license_allows_auditor_user?
).
and_return
(
true
)
choose
"user_access_level_auditor"
choose
"user_access_level_auditor"
click_button
"Save changes"
click_button
"Save changes"
end
end
it
"changes account type to be auditor"
do
it
"changes account type to be auditor"
do
user
.
reload
user
.
reload
expect
(
user
).
not_to
be_admin
expect
(
user
).
not_to
be_admin
expect
(
user
).
to
be_auditor
expect
(
user
).
to
be_auditor
end
end
end
end
describe
'Update shared runners quota'
do
describe
'Update shared runners quota'
do
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
,
shared_runners_enabled:
true
)
}
it
"shows page with new data"
do
it
"shows page with new data"
do
visit_edit_user
(
user
.
id
)
visit_edit_user
(
user
.
id
)
fill_in
"user_namespace_attributes_shared_runners_minutes_limit"
,
with:
"500"
fill_in
"user_namespace_attributes_shared_runners_minutes_limit"
,
with:
"500"
click_button
"Save changes"
click_button
"Save changes"
expect
(
page
).
to
have_content
(
'Pipeline minutes quota: 0 / 500'
)
expect
(
page
).
to
have_content
(
'Pipeline minutes quota: 0 / 500'
)
end
end
end
end
def
visit_edit_user
(
user_id
)
def
visit_edit_user
(
user_id
)
visit
admin_users_path
visit
admin_users_path
page
.
within
(
"[data-testid='user-actions-
#{
user_id
}
']"
)
do
page
.
within
(
"[data-testid='user-actions-
#{
user_id
}
']"
)
do
click_link
'Edit'
click_link
'Edit'
end
end
end
end
end
end
describe
'show user keys for SSH and LDAP'
do
describe
'show user keys for SSH and LDAP'
do
let_it_be
(
:key1
)
do
let_it_be
(
:key1
)
do
create
(
:ldap_key
,
user:
user
,
title:
"LDAP Key1"
)
create
(
:ldap_key
,
user:
user
,
title:
"LDAP Key1"
)
end
end
let_it_be
(
:key2
)
do
let_it_be
(
:key2
)
do
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key2"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key2"
)
create
(
:key
,
user:
user
,
title:
"ssh-rsa Key2"
,
key:
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC4FIEBXGi4bPU8kzxMefudPIJ08/gNprdNTaO9BR/ndy3+58s2HCTw2xCHcsuBmq+TsAqgEidVq4skpqoTMB+Uot5Uzp9z4764rc48dZiI661izoREoKnuRQSsRqUTHg5wrLzwxlQbl1MVfRWQpqiz/5KjBC7yLEb9AbusjnWBk8wvC1bQPQ1uLAauEA7d836tgaIsym9BrLsMVnR4P1boWD3Xp1B1T/ImJwAGHvRmP/ycIqmKdSpMdJXwxcb40efWVj0Ibbe7ii9eeoLdHACqevUZi6fwfbymdow+FeqlkPoHyGg3Cu4vD/D8+8cRc7mE/zGCWcQ15Var83Tczour Key2"
)
end
end
it
'only shows the delete button for regular keys'
do
it
'only shows the delete button for regular keys'
do
visit
admin_users_path
visit
admin_users_path
click_link
user
.
name
click_link
user
.
name
click_link
'SSH keys'
click_link
'SSH keys'
# Check that the regular Key shows the delete icon and the LDAPKey does not
# Check that the regular Key shows the delete icon and the LDAPKey does not
# SSH key should be the first in the list
# SSH key should be the first in the list
within
(
'ul.content-list li.key-list-item:nth-of-type(1)'
)
do
within
(
'ul.content-list li.key-list-item:nth-of-type(1)'
)
do
expect
(
page
).
to
have_content
(
key2
.
title
)
expect
(
page
).
to
have_content
(
key2
.
title
)
expect
(
page
).
to
have_button
(
'Delete'
)
expect
(
page
).
to
have_button
(
'Delete'
)
end
end
# Next, LDAP key
# Next, LDAP key
within
(
'ul.content-list li.key-list-item:nth-of-type(2)'
)
do
within
(
'ul.content-list li.key-list-item:nth-of-type(2)'
)
do
expect
(
page
).
to
have_content
(
key1
.
title
)
expect
(
page
).
to
have_content
(
key1
.
title
)
expect
(
page
).
not_to
have_button
(
'Delete'
)
expect
(
page
).
not_to
have_button
(
'Delete'
)
end
end
end
end
end
end
end
end
...
...
scripts/verify-tff-mapping
View file @
12e3dfbe
...
@@ -84,8 +84,8 @@ tests = [
...
@@ -84,8 +84,8 @@ tests = [
{
{
explanation:
'FOSS views should map to respective spec'
,
explanation:
'FOSS views should map to respective spec'
,
source:
'app/views/admin/
users/_user
.html.haml'
,
source:
'app/views/admin/
dashboard/index
.html.haml'
,
expected:
[
'spec/views/admin/
users/_user
.html.haml_spec.rb'
]
expected:
[
'spec/views/admin/
dashboard/index
.html.haml_spec.rb'
]
},
},
{
{
...
...
spec/features/admin/users/user_spec.rb
View file @
12e3dfbe
...
@@ -356,27 +356,19 @@ RSpec.describe 'Admin::Users::User' do
...
@@ -356,27 +356,19 @@ RSpec.describe 'Admin::Users::User' do
end
end
end
end
[
true
,
false
].
each
do
|
vue_admin_users
|
describe
'GET /admin/users'
,
:js
do
context
"with vue_admin_users feature flag set to
#{
vue_admin_users
}
"
,
js:
vue_admin_users
do
context
'user pending approval'
do
before
do
it
'shows user info'
,
:aggregate_failures
do
stub_feature_flags
(
vue_admin_users:
vue_admin_users
)
user
=
create
(
:user
,
:blocked_pending_approval
)
end
describe
'GET /admin/users'
do
context
'user pending approval'
do
it
'shows user info'
,
:aggregate_failures
do
user
=
create
(
:user
,
:blocked_pending_approval
)
visit
admin_users_path
visit
admin_users_path
click_link
'Pending approval'
click_link
'Pending approval'
click_link
user
.
name
click_link
user
.
name
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'Pending approval'
)
expect
(
page
).
to
have_content
(
'Pending approval'
)
expect
(
page
).
to
have_link
(
'Approve user'
)
expect
(
page
).
to
have_link
(
'Approve user'
)
expect
(
page
).
to
have_link
(
'Reject request'
)
expect
(
page
).
to
have_link
(
'Reject request'
)
end
end
end
end
end
end
end
end
...
...
spec/features/admin/users/users_spec.rb
View file @
12e3dfbe
...
@@ -11,291 +11,300 @@ RSpec.describe 'Admin::Users' do
...
@@ -11,291 +11,300 @@ RSpec.describe 'Admin::Users' do
gitlab_enable_admin_mode_sign_in
(
current_user
)
gitlab_enable_admin_mode_sign_in
(
current_user
)
end
end
[
true
,
false
].
each
do
|
vue_admin_users
|
describe
'GET /admin/users'
,
:js
do
context
"with vue_admin_users feature flag set to
#{
vue_admin_users
}
"
,
js:
vue_admin_users
do
before
do
before
do
visit
admin_users_path
stub_feature_flags
(
vue_admin_users:
vue_admin_users
)
end
end
describe
'GET /admin/users'
do
it
"is ok"
do
before
do
expect
(
current_path
).
to
eq
(
admin_users_path
)
visit
admin_users_path
end
end
it
"is ok"
do
it
"has users list"
do
expect
(
current_path
).
to
eq
(
admin_users_path
)
current_user
.
reload
end
it
"has users list"
do
expect
(
page
).
to
have_content
(
current_user
.
email
)
current_user
.
reload
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
current_user
.
created_at
.
strftime
(
'%e %b, %Y'
))
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'Projects'
)
expect
(
page
).
to
have_content
(
current_user
.
email
)
click_user_dropdown_toggle
(
user
.
id
)
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
current_user
.
created_at
.
strftime
(
'%e %b, %Y'
))
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
user
.
name
)
expect
(
page
).
to
have_content
(
'Projects'
)
click_user_dropdown_toggle
(
user
.
id
)
expect
(
page
).
to
have_button
(
'Block'
)
expect
(
page
).
to
have_button
(
'Deactivate'
)
expect
(
page
).
to
have_button
(
'Delete user'
)
expect
(
page
).
to
have_button
(
'Delete user and contributions'
)
end
expect
(
page
).
to
have_button
(
'Block'
)
it
'clicking edit user takes us to edit page'
,
:aggregate_failures
do
expect
(
page
).
to
have_button
(
'Deactivate'
)
page
.
within
(
"[data-testid='user-actions-
#{
user
.
id
}
']"
)
do
expect
(
page
).
to
have_button
(
'Delete user'
)
click_link
'Edit'
expect
(
page
).
to
have_button
(
'Delete user and contributions'
)
end
end
it
'clicking edit user takes us to edit page'
,
:aggregate_failures
do
expect
(
page
).
to
have_content
(
'Name'
)
page
.
within
(
"[data-testid='user-actions-
#{
user
.
id
}
']"
)
do
expect
(
page
).
to
have_content
(
'Password'
)
click_link
'Edit'
end
end
expect
(
page
).
to
have_content
(
'Name'
)
describe
'view extra user information'
do
expect
(
page
).
to
have_content
(
'Password'
)
it
'shows the user popover on hover'
,
:js
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/-/issues/11290'
do
e
nd
e
xpect
(
page
).
not_to
have_selector
(
'#__BV_popover_1__'
)
describe
'view extra user information'
do
first_user_link
=
page
.
first
(
'.js-user-link'
)
it
'shows the user popover on hover'
,
:js
,
quarantine:
'https://gitlab.com/gitlab-org/gitlab/-/issues/11290'
do
first_user_link
.
hover
expect
(
page
).
not_to
have_selector
(
'#__BV_popover_1__'
)
first_user_link
=
page
.
first
(
'.js-user-link'
)
expect
(
page
).
to
have_selector
(
'#__BV_popover_1__'
)
first_user_link
.
hover
end
end
expect
(
page
).
to
have_selector
(
'#__BV_popover_1__'
)
context
'user project count'
do
end
before
do
end
project
=
create
(
:project
)
project
.
add_maintainer
(
current_user
)
end
it
'displays count of users projects'
do
visit
admin_users_path
context
'user project count'
do
expect
(
page
.
find
(
"[data-testid='user-project-count-
#{
current_user
.
id
}
']"
).
text
).
to
eq
(
"1"
)
before
do
end
project
=
create
(
:project
)
end
project
.
add_maintainer
(
current_user
)
end
it
'displays count of users projects'
do
describe
'tabs'
do
visit
admin_users_path
it
'has multiple tabs to filter users'
do
expect
(
page
).
to
have_link
(
'Active'
,
href:
admin_users_path
)
expect
(
page
).
to
have_link
(
'Admins'
,
href:
admin_users_path
(
filter:
'admins'
))
expect
(
page
).
to
have_link
(
'2FA Enabled'
,
href:
admin_users_path
(
filter:
'two_factor_enabled'
))
expect
(
page
).
to
have_link
(
'2FA Disabled'
,
href:
admin_users_path
(
filter:
'two_factor_disabled'
))
expect
(
page
).
to
have_link
(
'External'
,
href:
admin_users_path
(
filter:
'external'
))
expect
(
page
).
to
have_link
(
'Blocked'
,
href:
admin_users_path
(
filter:
'blocked'
))
expect
(
page
).
to
have_link
(
'Deactivated'
,
href:
admin_users_path
(
filter:
'deactivated'
))
expect
(
page
).
to
have_link
(
'Without projects'
,
href:
admin_users_path
(
filter:
'wop'
))
end
expect
(
page
.
find
(
"[data-testid='user-project-count-
#{
current_user
.
id
}
']"
).
text
).
to
eq
(
"1"
)
context
'`Pending approval` tab'
do
end
before
do
visit
admin_users_path
end
end
describe
'tabs'
do
it
'shows the `Pending approval` tab'
do
it
'has multiple tabs to filter users'
do
expect
(
page
).
to
have_link
(
'Pending approval'
,
href:
admin_users_path
(
filter:
'blocked_pending_approval'
))
expect
(
page
).
to
have_link
(
'Active'
,
href:
admin_users_path
)
expect
(
page
).
to
have_link
(
'Admins'
,
href:
admin_users_path
(
filter:
'admins'
))
expect
(
page
).
to
have_link
(
'2FA Enabled'
,
href:
admin_users_path
(
filter:
'two_factor_enabled'
))
expect
(
page
).
to
have_link
(
'2FA Disabled'
,
href:
admin_users_path
(
filter:
'two_factor_disabled'
))
expect
(
page
).
to
have_link
(
'External'
,
href:
admin_users_path
(
filter:
'external'
))
expect
(
page
).
to
have_link
(
'Blocked'
,
href:
admin_users_path
(
filter:
'blocked'
))
expect
(
page
).
to
have_link
(
'Banned'
,
href:
admin_users_path
(
filter:
'banned'
))
expect
(
page
).
to
have_link
(
'Deactivated'
,
href:
admin_users_path
(
filter:
'deactivated'
))
expect
(
page
).
to
have_link
(
'Without projects'
,
href:
admin_users_path
(
filter:
'wop'
))
end
context
'`Pending approval` tab'
do
before
do
visit
admin_users_path
end
it
'shows the `Pending approval` tab'
do
expect
(
page
).
to
have_link
(
'Pending approval'
,
href:
admin_users_path
(
filter:
'blocked_pending_approval'
))
end
end
end
end
end
end
describe
'search and sort'
do
before_all
do
create
(
:user
,
name:
'Foo Bar'
,
last_activity_on:
3
.
days
.
ago
)
create
(
:user
,
name:
'Foo Baz'
,
last_activity_on:
2
.
days
.
ago
)
create
(
:user
,
name:
'Dmitriy'
)
end
describe
'search and sort'
do
it
'searches users by name'
do
before_all
do
visit
admin_users_path
(
search_query:
'Foo'
)
create
(
:user
,
name:
'Foo Bar'
,
last_activity_on:
3
.
days
.
ago
)
create
(
:user
,
name:
'Foo Baz'
,
last_activity_on:
2
.
days
.
ago
)
create
(
:user
,
name:
'Dmitriy'
)
end
it
'searches users by name'
do
expect
(
page
).
to
have_content
(
'Foo Bar'
)
visit
admin_users_path
(
search_query:
'Foo'
)
expect
(
page
).
to
have_content
(
'Foo Baz'
)
expect
(
page
).
not_to
have_content
(
'Dmitriy'
)
end
expect
(
page
).
to
have_content
(
'Foo Bar'
)
it
'sorts users by name'
do
expect
(
page
).
to
have_content
(
'Foo Baz'
)
visit
admin_users_path
expect
(
page
).
not_to
have_content
(
'Dmitriy'
)
end
it
'sorts users by name'
do
sort_by
(
'Name'
)
visit
admin_users_path
sort_by
(
'Name'
)
expect
(
first_row
.
text
).
to
include
(
'Dmitriy'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Bar'
)
end
expect
(
first_row
.
text
).
to
include
(
'Dmitriy'
)
it
'sorts search results only'
do
expect
(
second_row
.
text
).
to
include
(
'Foo Bar'
)
visit
admin_users_path
(
search_query:
'Foo'
)
end
it
'sorts search results only'
do
sort_by
(
'Name'
)
visit
admin_users_path
(
search_query:
'Foo'
)
expect
(
page
).
not_to
have_content
(
'Dmitriy'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
end
sort_by
(
'Name'
)
it
'searches with respect of sorting'
do
expect
(
page
).
not_to
have_content
(
'Dmitriy'
)
visit
admin_users_path
(
sort:
'Name'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
fill_in
:search_query
,
with:
'Foo'
end
click_button
(
'Search users'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
end
it
'searches with respect of sorting
'
do
it
'sorts users by recent last activity
'
do
visit
admin_users_path
(
sort:
'Name
'
)
visit
admin_users_path
(
search_query:
'Foo
'
)
fill_in
:search_query
,
with:
'Foo'
sort_by
(
'Recent last activity'
)
click_button
(
'Search users'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar
'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Baz
'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz
'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Bar
'
)
end
end
it
'sorts users by recen
t last activity'
do
it
'sorts users by oldes
t last activity'
do
visit
admin_users_path
(
search_query:
'Foo'
)
visit
admin_users_path
(
search_query:
'Foo'
)
sort_by
(
'Recen
t last activity'
)
sort_by
(
'Oldes
t last activity'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Baz'
)
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Bar'
)
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
end
end
end
it
'sorts users by oldest last activity'
do
describe
'Two-factor Authentication filters'
do
visit
admin_users_path
(
search_query:
'Foo'
)
it
'counts users who have enabled 2FA'
do
create
(
:user
,
:two_factor
)
sort_by
(
'Oldest last activity'
)
visit
admin_users_path
expect
(
first_row
.
text
).
to
include
(
'Foo Bar'
)
page
.
within
(
'.filter-two-factor-enabled small'
)
do
expect
(
second_row
.
text
).
to
include
(
'Foo Baz'
)
expect
(
page
).
to
have_content
(
'1'
)
end
end
end
end
describe
'Two-factor Authentication filters'
do
it
'filters by users who have enabled 2FA'
do
it
'counts users who have enabled 2FA'
do
user
=
create
(
:user
,
:two_factor
)
create
(
:user
,
:two_factor
)
visit
admin_users_path
visit
admin_users_path
click_link
'2FA Enabled'
page
.
within
(
'.filter-two-factor-enabled small'
)
do
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'1'
)
end
end
end
it
'filters by users who have
enabled 2FA'
do
it
'counts users who have not
enabled 2FA'
do
user
=
create
(
:user
,
:two_factor
)
visit
admin_users_path
visit
admin_users_path
page
.
within
(
'.filter-two-factor-disabled small'
)
do
click_link
'2FA Enabled'
expect
(
page
).
to
have_content
(
'2'
)
# Including admin
end
end
expect
(
page
).
to
have_content
(
user
.
email
)
it
'filters by users who have not enabled 2FA'
do
end
visit
admin_users_path
click_link
'2FA Disabled'
it
'counts users who have not enabled 2FA'
do
expect
(
page
).
to
have_content
(
user
.
email
)
visit
admin_users_path
end
end
page
.
within
(
'.filter-two-factor-disabled small'
)
do
describe
'Pending approval filter'
do
expect
(
page
).
to
have_content
(
'2'
)
# Including admin
it
'counts users who are pending approval'
do
end
create_list
(
:user
,
2
,
:blocked_pending_approval
)
end
it
'filters by users who have not enabled 2FA'
do
visit
admin_users_path
visit
admin_users_path
click_link
'2FA Disabled'
expect
(
page
).
to
have_content
(
user
.
email
)
page
.
within
(
'.filter-blocked-pending-approval small'
)
do
e
nd
e
xpect
(
page
).
to
have_content
(
'2'
)
end
end
end
describe
'Pending approval filter'
do
it
'filters by users who are pending approval'
do
it
'counts users who are pending approval'
do
user
=
create
(
:user
,
:blocked_pending_approval
)
create_list
(
:user
,
2
,
:blocked_pending_approval
)
visit
admin_users_path
visit
admin_users_path
click_link
'Pending approval'
page
.
within
(
'.filter-blocked-pending-approval small'
)
do
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'2'
)
end
end
end
end
it
'filters by users who are pending approval'
do
context
'when blocking/unblocking a user'
do
user
=
create
(
:user
,
:blocked_pending_approval
)
it
'shows confirmation and allows blocking and unblocking'
,
:js
do
expect
(
page
).
to
have_content
(
user
.
email
)
visit
admin_users_path
click_action_in_user_dropdown
(
user
.
id
,
'Block'
)
click_link
'Pending approval'
expect
(
page
).
to
have_content
(
user
.
email
)
wait_for_requests
end
end
expect
(
page
).
to
have_content
(
'Block user'
)
expect
(
page
).
to
have_content
(
'Blocking user has the following effects'
)
expect
(
page
).
to
have_content
(
'User will not be able to login'
)
expect
(
page
).
to
have_content
(
'Owned groups will be left'
)
context
'when blocking/unblocking a user'
do
find
(
'.modal-footer button'
,
text:
'Block'
).
click
it
'shows confirmation and allows blocking and unblocking'
,
:js
do
expect
(
page
).
to
have_content
(
user
.
email
)
click_action_in_user_dropdown
(
user
.
id
,
'Block'
)
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
'Successfully blocked'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'Block user'
)
click_link
'Blocked'
expect
(
page
).
to
have_content
(
'Blocking user has the following effects'
)
expect
(
page
).
to
have_content
(
'User will not be able to login'
)
expect
(
page
).
to
have_content
(
'Owned groups will be left'
)
find
(
'.modal-footer button'
,
text:
'Block'
).
click
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'Successfully blocked'
)
click_action_in_user_dropdown
(
user
.
id
,
'Unblock'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
click_link
'Blocked'
expect
(
page
).
to
have_content
(
'Unblock user'
)
expect
(
page
).
to
have_content
(
'You can always block their account again if needed.'
)
wait_for_requests
find
(
'.modal-footer button'
,
text:
'Unblock'
).
click
expect
(
page
).
to
have_content
(
user
.
email
)
wait_for_requests
click_action_in_user_dropdown
(
user
.
id
,
'Unblock'
)
expect
(
page
).
to
have_content
(
'Successfully unblocked'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
end
end
expect
(
page
).
to
have_content
(
'Unblock user'
)
context
'when deactivating/re-activating a user'
do
expect
(
page
).
to
have_content
(
'You can always block their account again if needed.'
)
it
'shows confirmation and allows deactivating and re-activating'
,
:js
do
expect
(
page
).
to
have_content
(
user
.
email
)
find
(
'.modal-footer button'
,
text:
'Unblock'
).
click
click_action_in_user_dropdown
(
user
.
id
,
'Deactivate'
)
wait_for_requests
expect
(
page
).
to
have_content
(
'Deactivate user'
)
expect
(
page
).
to
have_content
(
'Deactivating a user has the following effects'
)
expect
(
page
).
to
have_content
(
'The user will be logged out'
)
expect
(
page
).
to
have_content
(
'Personal projects, group and user history will be left intact'
)
expect
(
page
).
to
have_content
(
'Successfully unblocked'
)
find
(
'.modal-footer button'
,
text:
'Deactivate'
).
click
expect
(
page
).
not_to
have_content
(
user
.
email
)
end
end
context
'when deactivating/re-activating a user'
do
wait_for_requests
it
'shows confirmation and allows deactivating and re-activating'
,
:js
do
expect
(
page
).
to
have_content
(
user
.
email
)
click_action_in_user_dropdown
(
user
.
id
,
'Deactivate'
)
expect
(
page
).
to
have_content
(
'Successfully deactivated'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'Deactivate user'
)
click_link
'Deactivated'
expect
(
page
).
to
have_content
(
'Deactivating a user has the following effects'
)
expect
(
page
).
to
have_content
(
'The user will be logged out'
)
expect
(
page
).
to
have_content
(
'Personal projects, group and user history will be left intact'
)
find
(
'.modal-footer button'
,
text:
'Deactivate'
).
click
wait_for_requests
wait_for_requests
expect
(
page
).
to
have_content
(
user
.
email
)
expect
(
page
).
to
have_content
(
'Successfully deactivated'
)
click_action_in_user_dropdown
(
user
.
id
,
'Activate'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
click_link
'Deactivated'
expect
(
page
).
to
have_content
(
'Activate user'
)
expect
(
page
).
to
have_content
(
'You can always deactivate their account again if needed.'
)
wait_for_requests
find
(
'.modal-footer button'
,
text:
'Activate'
).
click
expect
(
page
).
to
have_content
(
user
.
email
)
wait_for_requests
click_action_in_user_dropdown
(
user
.
id
,
'Activate'
)
expect
(
page
).
to
have_content
(
'Successfully activated'
)
expect
(
page
).
not_to
have_content
(
user
.
email
)
end
end
expect
(
page
).
to
have_content
(
'Activate user'
)
describe
'internal users'
do
expect
(
page
).
to
have_content
(
'You can always deactivate their account again if needed.'
)
context
'when showing a `Ghost User`'
do
let_it_be
(
:ghost_user
)
{
create
(
:user
,
:ghost
)
}
find
(
'.modal-footer button'
,
text:
'Activate'
).
click
it
'does not render actions dropdown'
do
expect
(
page
).
not_to
have_css
(
"[data-testid='user-actions-
#{
ghost_user
.
id
}
'] [data-testid='dropdown-toggle']"
)
end
end
wait_for_requests
context
'when showing a `Bot User`'
do
let_it_be
(
:bot_user
)
{
create
(
:user
,
user_type: :alert_bot
)
}
expect
(
page
).
to
have_content
(
'Successfully activated'
)
it
'does not render actions dropdown'
do
expect
(
page
).
not_to
have_content
(
user
.
email
)
expect
(
page
).
not_to
have_css
(
"[data-testid='user-actions-
#{
bot_user
.
id
}
'] [data-testid='dropdown-toggle']"
)
end
end
end
end
end
end
end
...
...
spec/views/admin/users/_user.html.haml_spec.rb
deleted
100644 → 0
View file @
f2d63afe
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
'admin/users/_user.html.haml'
do
before
do
allow
(
view
).
to
receive
(
:user
).
and_return
(
user
)
end
context
'internal users'
do
context
'when showing a `Ghost User`'
do
let
(
:user
)
{
create
(
:user
,
:ghost
)
}
it
'does not render action buttons'
do
render
expect
(
rendered
).
not_to
have_selector
(
'.table-action-buttons'
)
end
end
context
'when showing a `Bot User`'
do
let
(
:user
)
{
create
(
:user
,
user_type: :alert_bot
)
}
it
'does not render action buttons'
do
render
expect
(
rendered
).
not_to
have_selector
(
'.table-action-buttons'
)
end
end
context
'when showing a `Migration User`'
do
let
(
:user
)
{
create
(
:user
,
user_type: :migration_bot
)
}
it
'does not render action buttons'
do
render
expect
(
rendered
).
not_to
have_selector
(
'.table-action-buttons'
)
end
end
end
context
'when showing an external user'
do
let
(
:user
)
{
create
(
:user
)
}
it
'renders action buttons'
do
render
expect
(
rendered
).
to
have_selector
(
'.table-action-buttons'
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment