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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
d249da1c
Commit
d249da1c
authored
Mar 04, 2016
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Specs on force deleting of a user
parent
b221d11a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
7 deletions
+43
-7
app/services/delete_user_service.rb
app/services/delete_user_service.rb
+1
-1
spec/workers/delete_user_worker_spec.rb
spec/workers/delete_user_worker_spec.rb
+42
-6
No files found.
app/services/delete_user_service.rb
View file @
d249da1c
...
@@ -12,7 +12,7 @@ class DeleteUserService
...
@@ -12,7 +12,7 @@ class DeleteUserService
end
end
user
.
solo_owned_groups
.
each
do
|
group
|
user
.
solo_owned_groups
.
each
do
|
group
|
De
lete
GroupService
.
new
(
group
,
current_user
).
execute
De
stroy
GroupService
.
new
(
group
,
current_user
).
execute
end
end
user
.
personal_projects
.
each
do
|
project
|
user
.
personal_projects
.
each
do
|
project
|
...
...
spec/workers/delete_user_worker_spec.rb
View file @
d249da1c
...
@@ -7,16 +7,52 @@ describe DeleteUserWorker do
...
@@ -7,16 +7,52 @@ describe DeleteUserWorker do
let!
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
owner:
user
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
let!
(
:project
)
{
create
(
:project
,
namespace:
namespace
)
}
before
do
context
'no force flag given'
do
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
)
before
do
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
)
end
it
'deletes all personal projects'
do
expect
{
Project
.
find
(
project
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'deletes the user'
do
expect
{
User
.
find
(
user
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
end
end
it
'deletes all personal projects'
do
context
"solo owned groups present"
do
expect
{
Project
.
find
(
project
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
let
(
:solo_owned
)
{
create
(
:group
)
}
let
(
:member
)
{
create
(
:group_member
)
}
let
(
:user
)
{
user
=
member
.
user
}
before
do
solo_owned
.
group_members
=
[
member
]
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
)
end
it
'does not delete the user'
do
expect
(
User
.
find
(
user
.
id
)).
to
eq
user
end
end
end
it
'deletes the user'
do
context
"deletions with force"
do
expect
{
User
.
find
(
user
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
let
(
:solo_owned
)
{
create
(
:group
)
}
let
(
:member
)
{
create
(
:group_member
)
}
let
(
:user
)
{
user
=
member
.
user
}
before
do
solo_owned
.
group_members
=
[
member
]
DeleteUserWorker
.
new
.
perform
(
current_user
.
id
,
user
.
id
,
"force"
=>
true
)
end
it
'deletes solo owned groups'
do
expect
{
Project
.
find
(
solo_owned
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
it
'deletes the user'
do
expect
{
User
.
find
(
user
.
id
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotFound
)
end
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