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
f4433ad1
Commit
f4433ad1
authored
Nov 22, 2017
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move EE-specific ProjectTeam code to a EE module and remove EE-specific code in Members API
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
d9014ba8
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
16 deletions
+91
-16
app/models/project_team.rb
app/models/project_team.rb
+2
-10
ee/app/models/ee/project_team.rb
ee/app/models/ee/project_team.rb
+25
-0
lib/api/members.rb
lib/api/members.rb
+0
-6
spec/ee/models/project_team_spec.rb
spec/ee/models/project_team_spec.rb
+40
-0
spec/models/project_team_spec.rb
spec/models/project_team_spec.rb
+24
-0
No files found.
app/models/project_team.rb
View file @
f4433ad1
class
ProjectTeam
include
BulkMemberAccessLoad
prepend
EE
::
ProjectTeam
attr_accessor
:project
def
initialize
(
project
)
...
...
@@ -40,8 +42,6 @@ class ProjectTeam
end
def
add_users
(
users
,
access_level
,
current_user:
nil
,
expires_at:
nil
)
return
false
if
group_member_lock
ProjectMember
.
add_users
(
project
,
users
,
...
...
@@ -173,12 +173,4 @@ class ProjectTeam
def
group
project
.
group
end
def
group_member_lock
group
&&
group
.
membership_lock
end
def
merge_max!
(
first_hash
,
second_hash
)
first_hash
.
merge!
(
second_hash
)
{
|
_key
,
old
,
new
|
old
>
new
?
old
:
new
}
end
end
ee/app/models/ee/project_team.rb
0 → 100644
View file @
f4433ad1
module
EE
module
ProjectTeam
extend
ActiveSupport
::
Concern
def
add_users
(
users
,
access_level
,
current_user:
nil
,
expires_at:
nil
)
raise
NotImplementedError
unless
defined?
(
super
)
return
false
if
group_member_lock
super
end
def
add_user
(
user
,
access_level
,
current_user:
nil
,
expires_at:
nil
)
raise
NotImplementedError
unless
defined?
(
super
)
return
false
if
group_member_lock
super
end
private
def
group_member_lock
group
&&
group
.
membership_lock
end
end
end
lib/api/members.rb
View file @
f4433ad1
...
...
@@ -54,12 +54,6 @@ module API
source
=
find_source
(
source_type
,
params
[
:id
])
authorize_admin_source!
(
source_type
,
source
)
## EE specific
if
source_type
==
'project'
&&
source
.
group
&&
source
.
group
.
membership_lock
not_allowed!
end
## EE specific
member
=
source
.
members
.
find_by
(
user_id:
params
[
:user_id
])
conflict!
(
'Member already exists'
)
if
member
...
...
spec/ee/models/project_team_spec.rb
0 → 100644
View file @
f4433ad1
require
"spec_helper"
describe
ProjectTeam
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:project
,
group:
group
)
}
describe
'#add_users'
do
let
(
:user1
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
context
'when group membership is locked'
do
before
do
group
.
update_attribute
(
:membership_lock
,
true
)
end
it
'does not add the given users to the team'
do
project
.
team
.
add_users
([
user1
,
user2
],
:reporter
)
expect
(
project
.
team
.
reporter?
(
user1
)).
to
be
(
false
)
expect
(
project
.
team
.
reporter?
(
user2
)).
to
be
(
false
)
end
end
end
describe
'#add_user'
do
let
(
:user
)
{
create
(
:user
)
}
context
'when group membership is locked'
do
before
do
group
.
update_attribute
(
:membership_lock
,
true
)
end
it
'does not add the given user to the team'
do
project
.
team
.
add_user
(
user
,
:reporter
)
expect
(
project
.
team
.
reporter?
(
user
)).
to
be
(
false
)
end
end
end
end
spec/models/project_team_spec.rb
View file @
f4433ad1
...
...
@@ -178,6 +178,30 @@ describe ProjectTeam do
end
end
describe
'#add_users'
do
let
(
:user1
)
{
create
(
:user
)
}
let
(
:user2
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
it
'add the given users to the team'
do
project
.
team
.
add_users
([
user1
,
user2
],
:reporter
)
expect
(
project
.
team
.
reporter?
(
user1
)).
to
be
(
true
)
expect
(
project
.
team
.
reporter?
(
user2
)).
to
be
(
true
)
end
end
describe
'#add_user'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
it
'add the given user to the team'
do
project
.
team
.
add_user
(
user
,
:reporter
)
expect
(
project
.
team
.
reporter?
(
user
)).
to
be
(
true
)
end
end
describe
"#human_max_access"
do
it
'returns Master role'
do
user
=
create
(
: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