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
7de75920
Unverified
Commit
7de75920
authored
Apr 17, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor controller code that creates project/group members
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
eeaeb275
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
25 additions
and
30 deletions
+25
-30
membership_actions.rb
app/controllers/concerns/membership_actions.rb
+12
-0
group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+0
-15
project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+0
-12
project.rb
app/models/project.rb
+1
-1
create_service.rb
app/services/members/create_service.rb
+7
-1
dz-refactor-create-members.yml
changelogs/unreleased/dz-refactor-create-members.yml
+4
-0
project_members_controller_spec.rb
spec/controllers/projects/project_members_controller_spec.rb
+1
-1
No files found.
app/controllers/concerns/membership_actions.rb
View file @
7de75920
module
MembershipActions
extend
ActiveSupport
::
Concern
def
create
status
=
Members
::
CreateService
.
new
(
membershipable
,
current_user
,
params
).
execute
redirect_url
=
polymorphic_url
([
membershipable
,
:members
])
if
status
redirect_to
redirect_url
,
notice:
'Users were successfully added.'
else
redirect_to
redirect_url
,
alert:
'No users specified.'
end
end
def
request_access
membershipable
.
request_access
(
current_user
)
...
...
app/controllers/groups/group_members_controller.rb
View file @
7de75920
...
...
@@ -21,21 +21,6 @@ class Groups::GroupMembersController < Groups::ApplicationController
@group_member
=
@group
.
group_members
.
new
end
def
create
if
params
[
:user_ids
].
blank?
return
redirect_to
(
group_group_members_path
(
@group
),
alert:
'No users specified.'
)
end
@group
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
current_user:
current_user
,
expires_at:
params
[
:expires_at
]
)
redirect_to
group_group_members_path
(
@group
),
notice:
'Users were successfully added.'
end
def
update
@group_member
=
@group
.
group_members
.
find
(
params
[
:id
])
...
...
app/controllers/projects/project_members_controller.rb
View file @
7de75920
...
...
@@ -10,18 +10,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
redirect_to
namespace_project_settings_members_path
(
@project
.
namespace
,
@project
,
sort:
sort
)
end
def
create
status
=
Members
::
CreateService
.
new
(
@project
,
current_user
,
params
).
execute
redirect_url
=
namespace_project_settings_members_path
(
@project
.
namespace
,
@project
)
if
status
redirect_to
redirect_url
,
notice:
'Users were successfully added.'
else
redirect_to
redirect_url
,
alert:
'No users or groups specified.'
end
end
def
update
@project_member
=
@project
.
project_members
.
find
(
params
[
:id
])
...
...
app/models/project.rb
View file @
7de75920
...
...
@@ -181,7 +181,7 @@ class Project < ActiveRecord::Base
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:count
,
to: :forks
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
delegate
:add_user
,
to: :team
delegate
:add_user
,
:add_users
,
to: :team
delegate
:add_guest
,
:add_reporter
,
:add_developer
,
:add_master
,
to: :team
delegate
:empty_repo?
,
to: :repository
...
...
app/services/members/create_service.rb
View file @
7de75920
module
Members
class
CreateService
<
BaseService
def
initialize
(
source
,
current_user
,
params
=
{})
@source
=
source
@current_user
=
current_user
@params
=
params
end
def
execute
return
false
if
params
[
:user_ids
].
blank?
project
.
team
.
add_users
(
@source
.
add_users
(
params
[
:user_ids
].
split
(
','
),
params
[
:access_level
],
expires_at:
params
[
:expires_at
],
...
...
changelogs/unreleased/dz-refactor-create-members.yml
0 → 100644
View file @
7de75920
---
title
:
Refactor code that creates project/group members
merge_request
:
10735
author
:
spec/controllers/projects/project_members_controller_spec.rb
View file @
7de75920
...
...
@@ -55,7 +55,7 @@ describe Projects::ProjectMembersController do
user_ids:
''
,
access_level:
Gitlab
::
Access
::
GUEST
expect
(
response
).
to
set_flash
.
to
'No users
or groups
specified.'
expect
(
response
).
to
set_flash
.
to
'No users specified.'
expect
(
response
).
to
redirect_to
(
namespace_project_settings_members_path
(
project
.
namespace
,
project
))
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