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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
ed86faeb
Commit
ed86faeb
authored
May 18, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix: Deleting an invited member causes 500 error
parent
72119e7f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
1 deletion
+34
-1
app/services/members/authorized_destroy_service.rb
app/services/members/authorized_destroy_service.rb
+1
-1
spec/factories/group_members.rb
spec/factories/group_members.rb
+6
-0
spec/factories/project_members.rb
spec/factories/project_members.rb
+6
-0
spec/services/members/authorized_destroy_service_spec.rb
spec/services/members/authorized_destroy_service_spec.rb
+21
-0
No files found.
app/services/members/authorized_destroy_service.rb
View file @
ed86faeb
...
@@ -10,7 +10,7 @@ module Members
...
@@ -10,7 +10,7 @@ module Members
return
false
if
member
.
is_a?
(
GroupMember
)
&&
member
.
source
.
last_owner?
(
member
.
user
)
return
false
if
member
.
is_a?
(
GroupMember
)
&&
member
.
source
.
last_owner?
(
member
.
user
)
Member
.
transaction
do
Member
.
transaction
do
unassign_issues_and_merge_requests
(
member
)
unassign_issues_and_merge_requests
(
member
)
unless
member
.
invite?
member
.
destroy
member
.
destroy
end
end
...
...
spec/factories/group_members.rb
View file @
ed86faeb
...
@@ -10,5 +10,11 @@ FactoryGirl.define do
...
@@ -10,5 +10,11 @@ FactoryGirl.define do
trait
(
:master
)
{
access_level
GroupMember
::
MASTER
}
trait
(
:master
)
{
access_level
GroupMember
::
MASTER
}
trait
(
:owner
)
{
access_level
GroupMember
::
OWNER
}
trait
(
:owner
)
{
access_level
GroupMember
::
OWNER
}
trait
(
:access_request
)
{
requested_at
Time
.
now
}
trait
(
:access_request
)
{
requested_at
Time
.
now
}
trait
(
:invited
)
do
user_id
nil
invite_token
'xxx'
invite_email
'email@email.com'
end
end
end
end
end
spec/factories/project_members.rb
View file @
ed86faeb
...
@@ -9,5 +9,11 @@ FactoryGirl.define do
...
@@ -9,5 +9,11 @@ FactoryGirl.define do
trait
(
:developer
)
{
access_level
ProjectMember
::
DEVELOPER
}
trait
(
:developer
)
{
access_level
ProjectMember
::
DEVELOPER
}
trait
(
:master
)
{
access_level
ProjectMember
::
MASTER
}
trait
(
:master
)
{
access_level
ProjectMember
::
MASTER
}
trait
(
:access_request
)
{
requested_at
Time
.
now
}
trait
(
:access_request
)
{
requested_at
Time
.
now
}
trait
(
:invited
)
do
user_id
nil
invite_token
'xxx'
invite_email
'email@email.com'
end
end
end
end
end
spec/services/members/authorized_destroy_service_spec.rb
View file @
ed86faeb
...
@@ -10,6 +10,27 @@ describe Members::AuthorizedDestroyService, services: true do
...
@@ -10,6 +10,27 @@ describe Members::AuthorizedDestroyService, services: true do
Issue
.
assigned_to
(
user
).
count
+
MergeRequest
.
assigned_to
(
user
).
count
Issue
.
assigned_to
(
user
).
count
+
MergeRequest
.
assigned_to
(
user
).
count
end
end
context
'Invited users'
do
# Regression spec for issue: https://gitlab.com/gitlab-org/gitlab-ce/issues/32504
it
'destroys invited project member'
do
project
.
team
<<
[
member_user
,
:developer
]
member
=
create
:project_member
,
:invited
,
project:
project
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
Member
.
count
}.
from
(
2
).
to
(
1
)
end
it
'destroys invited group member'
do
group
.
add_developer
(
member_user
)
member
=
create
:group_member
,
:invited
,
group:
group
expect
{
described_class
.
new
(
member
,
member_user
).
execute
}
.
to
change
{
Member
.
count
}.
from
(
2
).
to
(
1
)
end
end
context
'Group member'
do
context
'Group member'
do
it
"unassigns issues and merge requests"
do
it
"unassigns issues and merge requests"
do
group
.
add_developer
(
member_user
)
group
.
add_developer
(
member_user
)
...
...
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