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
9f019158
Commit
9f019158
authored
Feb 06, 2020
by
Tan Le
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move specs to correct folder
parent
d28a865d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
74 deletions
+66
-74
ee/spec/services/ee/users/destroy_service_spec.rb
ee/spec/services/ee/users/destroy_service_spec.rb
+66
-0
ee/spec/services/users/destroy_service_spec.rb
ee/spec/services/users/destroy_service_spec.rb
+0
-74
No files found.
ee/spec/services/ee/users/destroy_service_spec.rb
View file @
9f019158
...
...
@@ -16,4 +16,70 @@ describe Users::DestroyService do
end
.
to
change
{
project
.
reload
.
mirror_user
}.
from
(
mirror_user
).
to
(
new_mirror_user
)
end
end
describe
'audit events'
do
let
(
:current_user
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:user
)
}
subject
(
:service
)
{
described_class
.
new
(
current_user
)
}
before
do
stub_licensed_features
(
admin_audit_log:
true
)
end
context
'soft delete'
do
let
(
:hard_delete
)
{
false
}
context
'when user destroy operation succeeds'
do
it
'logs audit events for ghost user migration and destroy operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
(
3
)).
to
contain_exactly
(
have_attributes
(
details:
hash_including
(
change:
'email address'
)),
have_attributes
(
details:
hash_including
(
change:
'username'
)),
have_attributes
(
details:
hash_including
(
remove:
'user'
))
)
end
end
context
'when user destroy operation fails'
do
before
do
allow
(
user
).
to
receive
(
:destroy
).
and_return
(
user
)
end
it
'logs audit events for ghost user migration operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
(
2
)).
to
contain_exactly
(
have_attributes
(
details:
hash_including
(
change:
'email address'
)),
have_attributes
(
details:
hash_including
(
change:
'username'
))
)
end
end
end
context
'hard delete'
do
let
(
:hard_delete
)
{
true
}
context
'when user destroy operation succeeds'
do
it
'logs audit events for destroy operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
)
.
to
have_attributes
(
details:
hash_including
(
remove:
'user'
))
end
end
context
'when user destroy operation fails'
do
before
do
allow
(
user
).
to
receive
(
:destroy
).
and_return
(
user
)
end
it
'does not log any audit event'
do
expect
{
service
.
execute
(
user
,
hard_delete:
hard_delete
)
}
.
not_to
change
{
AuditEvent
.
count
}
end
end
end
end
end
ee/spec/services/users/destroy_service_spec.rb
deleted
100644 → 0
View file @
d28a865d
# frozen_string_literal: true
require
'spec_helper'
describe
Users
::
DestroyService
do
let
(
:current_user
)
{
create
(
:admin
)
}
subject
(
:service
)
{
described_class
.
new
(
current_user
)
}
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
describe
'audit events'
do
before
do
stub_licensed_features
(
admin_audit_log:
true
)
end
context
'soft delete'
do
let
(
:hard_delete
)
{
false
}
context
'when user destroy operation succeeds'
do
it
'logs audit events for ghost user migration and destroy operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
(
3
)).
to
contain_exactly
(
have_attributes
(
details:
hash_including
(
change:
'email address'
)),
have_attributes
(
details:
hash_including
(
change:
'username'
)),
have_attributes
(
details:
hash_including
(
remove:
'user'
))
)
end
end
context
'when user destroy operation fails'
do
before
do
allow
(
user
).
to
receive
(
:destroy
).
and_return
(
user
)
end
it
'logs audit events for ghost user migration operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
(
2
)).
to
contain_exactly
(
have_attributes
(
details:
hash_including
(
change:
'email address'
)),
have_attributes
(
details:
hash_including
(
change:
'username'
))
)
end
end
end
context
'hard delete'
do
let
(
:hard_delete
)
{
true
}
context
'when user destroy operation succeeds'
do
it
'logs audit events for destroy operation'
do
service
.
execute
(
user
,
hard_delete:
hard_delete
)
expect
(
AuditEvent
.
last
)
.
to
have_attributes
(
details:
hash_including
(
remove:
'user'
))
end
end
context
'when user destroy operation fails'
do
before
do
allow
(
user
).
to
receive
(
:destroy
).
and_return
(
user
)
end
it
'does not log any audit event'
do
expect
{
service
.
execute
(
user
,
hard_delete:
hard_delete
)
}
.
not_to
change
{
AuditEvent
.
count
}
end
end
end
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