BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
e80d7a80
Commit
e80d7a80
authored
Jun 22, 2015
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix error when deleting a user who has projects
Closes #1856 Closes
https://github.com/gitlabhq/gitlabhq/issues/9394
parent
88343897
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
3 deletions
+34
-3
CHANGELOG
CHANGELOG
+1
-0
users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
registrations_controller.rb
app/controllers/registrations_controller.rb
+1
-1
delete_user_service.rb
app/services/delete_user_service.rb
+6
-0
users.rb
lib/api/users.rb
+1
-1
users_controller_spec.rb
spec/controllers/admin/users_controller_spec.rb
+24
-0
No files found.
CHANGELOG
View file @
e80d7a80
Please view this file on the master branch, on stable branches it's out of date.
v 7.13.0 (unreleased)
- Fix error when deleting a user who has projects (Stan Hu)
- Update maintenance documentation to explain no need to recompile asssets for omnibus installations (Stan Hu)
- Support commenting on diffs in side-by-side mode (Stan Hu)
- Fix JavaScript error when clicking on the comment button on a diff line that has a comment already (Stan Hu)
...
...
app/controllers/admin/users_controller.rb
View file @
e80d7a80
...
...
@@ -86,7 +86,7 @@ class Admin::UsersController < Admin::ApplicationController
end
def
destroy
DeleteUserService
.
new
.
execute
(
user
)
DeleteUserService
.
new
(
current_user
)
.
execute
(
user
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
admin_users_path
}
...
...
app/controllers/registrations_controller.rb
View file @
e80d7a80
...
...
@@ -6,7 +6,7 @@ class RegistrationsController < Devise::RegistrationsController
end
def
destroy
DeleteUserService
.
new
.
execute
(
current_user
)
DeleteUserService
.
new
(
current_user
)
.
execute
(
current_user
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
new_user_session_path
,
notice:
"Account successfully removed."
}
...
...
app/services/delete_user_service.rb
View file @
e80d7a80
class
DeleteUserService
attr_accessor
:current_user
def
initialize
(
current_user
)
@current_user
=
current_user
end
def
execute
(
user
)
if
user
.
solo_owned_groups
.
present?
user
.
errors
[
:base
]
<<
'You must transfer ownership or delete groups before you can remove user'
...
...
lib/api/users.rb
View file @
e80d7a80
...
...
@@ -194,7 +194,7 @@ module API
user
=
User
.
find_by
(
id:
params
[
:id
])
if
user
DeleteUserService
.
new
.
execute
(
user
)
DeleteUserService
.
new
(
current_user
)
.
execute
(
user
)
else
not_found!
(
'User'
)
end
...
...
spec/controllers/admin/users_controller_spec.rb
0 → 100644
View file @
e80d7a80
require
'spec_helper'
describe
Admin
::
UsersController
do
let
(
:admin
)
{
create
(
:admin
)
}
before
do
sign_in
(
admin
)
end
describe
'DELETE #user with projects'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
namespace:
user
.
namespace
)
}
before
do
project
.
team
<<
[
user
,
:developer
]
end
it
'deletes user'
do
delete
:destroy
,
id:
user
.
username
,
format: :json
expect
(
response
.
status
).
to
eq
(
200
)
expect
{
User
.
find
(
user
.
id
)
}.
to
raise_exception
(
ActiveRecord
::
RecordNotFound
)
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