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
Jérome Perrin
gitlab-ce
Commits
b2c8dc6f
Commit
b2c8dc6f
authored
Aug 02, 2016
by
Adam Niedzielski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace optional parameters with keyword arguments.
parent
420e5903
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
14 deletions
+45
-14
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+6
-1
app/models/group.rb
app/models/group.rb
+1
-1
app/models/member.rb
app/models/member.rb
+1
-1
app/models/members/project_member.rb
app/models/members/project_member.rb
+8
-2
app/models/project_team.rb
app/models/project_team.rb
+5
-5
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+12
-2
spec/models/member_spec.rb
spec/models/member_spec.rb
+12
-2
No files found.
app/controllers/projects/project_members_controller.rb
View file @
b2c8dc6f
...
...
@@ -36,7 +36,12 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
def
create
@project
.
team
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
current_user
,
params
[
:expires_at
])
@project
.
team
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
expires_at:
params
[
:expires_at
],
current_user:
current_user
)
redirect_to
namespace_project_project_members_path
(
@project
.
namespace
,
@project
)
end
...
...
app/models/group.rb
View file @
b2c8dc6f
...
...
@@ -97,7 +97,7 @@ class Group < Namespace
def
add_users
(
user_ids
,
access_level
,
current_user
=
nil
)
user_ids
.
each
do
|
user_id
|
Member
.
add_user
(
self
.
group_members
,
user_id
,
access_level
,
current_user
)
Member
.
add_user
(
self
.
group_members
,
user_id
,
access_level
,
current_user
:
current_user
)
end
end
...
...
app/models/member.rb
View file @
b2c8dc6f
...
...
@@ -74,7 +74,7 @@ class Member < ActiveRecord::Base
user
end
def
add_user
(
members
,
user_id
,
access_level
,
current_user
=
nil
,
expires_at
=
nil
)
def
add_user
(
members
,
user_id
,
access_level
,
current_user
:
nil
,
expires_at:
nil
)
user
=
user_for_id
(
user_id
)
# `user` can be either a User object or an email to be invited
...
...
app/models/members/project_member.rb
View file @
b2c8dc6f
...
...
@@ -33,7 +33,7 @@ class ProjectMember < Member
# :master
# )
#
def
add_users_into_projects
(
project_ids
,
user_ids
,
access
,
current_user
=
nil
,
expires_at
=
nil
)
def
add_users_into_projects
(
project_ids
,
user_ids
,
access
,
current_user
:
nil
,
expires_at:
nil
)
access_level
=
if
roles_hash
.
has_key?
(
access
)
roles_hash
[
access
]
elsif
roles_hash
.
values
.
include?
(
access
.
to_i
)
...
...
@@ -49,7 +49,13 @@ class ProjectMember < Member
project
=
Project
.
find
(
project_id
)
users
.
each
do
|
user
|
Member
.
add_user
(
project
.
project_members
,
user
,
access_level
,
current_user
,
expires_at
)
Member
.
add_user
(
project
.
project_members
,
user
,
access_level
,
current_user:
current_user
,
expires_at:
expires_at
)
end
end
end
...
...
app/models/project_team.rb
View file @
b2c8dc6f
...
...
@@ -15,7 +15,7 @@ class ProjectTeam
users
,
access
,
current_user
=
*
args
if
users
.
respond_to?
(
:each
)
add_users
(
users
,
access
,
current_user
)
add_users
(
users
,
access
,
current_user
:
current_user
)
else
add_user
(
users
,
access
,
current_user
)
end
...
...
@@ -33,18 +33,18 @@ class ProjectTeam
member
end
def
add_users
(
users
,
access
,
current_user
=
nil
,
expires_at
=
nil
)
def
add_users
(
users
,
access
,
current_user
:
nil
,
expires_at:
nil
)
ProjectMember
.
add_users_into_projects
(
[
project
.
id
],
users
,
access
,
current_user
,
expires_at
current_user
:
current_user
,
expires_at
:
expires_at
)
end
def
add_user
(
user
,
access
,
current_user
=
nil
)
add_users
([
user
],
access
,
current_user
)
add_users
([
user
],
access
,
current_user
:
current_user
)
end
# Remove all users from project team
...
...
spec/mailers/notify_spec.rb
View file @
b2c8dc6f
...
...
@@ -493,7 +493,12 @@ describe Notify do
end
def
invite_to_project
(
project
:,
email
:,
inviter
:)
ProjectMember
.
add_user
(
project
.
project_members
,
'toto@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
inviter
)
Member
.
add_user
(
project
.
project_members
,
'toto@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
current_user:
inviter
)
project
.
project_members
.
invite
.
last
end
...
...
@@ -740,7 +745,12 @@ describe Notify do
end
def
invite_to_group
(
group
:,
email
:,
inviter
:)
GroupMember
.
add_user
(
group
.
group_members
,
'toto@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
inviter
)
Member
.
add_user
(
group
.
group_members
,
'toto@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
current_user:
inviter
)
group
.
group_members
.
invite
.
last
end
...
...
spec/models/member_spec.rb
View file @
b2c8dc6f
...
...
@@ -65,11 +65,21 @@ describe Member, models: true do
@master_user
=
create
(
:user
).
tap
{
|
u
|
project
.
team
<<
[
u
,
:master
]
}
@master
=
project
.
members
.
find_by
(
user_id:
@master_user
.
id
)
ProjectMember
.
add_user
(
project
.
members
,
'toto1@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
@master_user
)
Member
.
add_user
(
project
.
members
,
'toto1@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
current_user:
@master_user
)
@invited_member
=
project
.
members
.
invite
.
find_by_invite_email
(
'toto1@example.com'
)
accepted_invite_user
=
build
(
:user
)
ProjectMember
.
add_user
(
project
.
members
,
'toto2@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
@master_user
)
Member
.
add_user
(
project
.
members
,
'toto2@example.com'
,
Gitlab
::
Access
::
DEVELOPER
,
current_user:
@master_user
)
@accepted_invite_member
=
project
.
members
.
invite
.
find_by_invite_email
(
'toto2@example.com'
).
tap
{
|
u
|
u
.
accept_invite!
(
accepted_invite_user
)
}
requested_user
=
create
(
:user
).
tap
{
|
u
|
project
.
request_access
(
u
)
}
...
...
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