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
Boxiang Sun
gitlab-ce
Commits
395fca14
Commit
395fca14
authored
Apr 17, 2017
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor members controller destroy action
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
7de75920
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
25 deletions
+30
-25
app/controllers/concerns/membership_actions.rb
app/controllers/concerns/membership_actions.rb
+29
-3
app/controllers/groups/group_members_controller.rb
app/controllers/groups/group_members_controller.rb
+0
-9
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+0
-12
spec/controllers/projects/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 @
395fca14
...
...
@@ -4,7 +4,7 @@ module MembershipActions
def
create
status
=
Members
::
CreateService
.
new
(
membershipable
,
current_user
,
params
).
execute
redirect_url
=
polymorphic_url
([
membershipable
,
:members
])
redirect_url
=
members_page_url
if
status
redirect_to
redirect_url
,
notice:
'Users were successfully added.'
...
...
@@ -13,6 +13,20 @@ module MembershipActions
end
end
def
destroy
Members
::
DestroyService
.
new
(
membershipable
,
current_user
,
params
).
execute
(
:all
)
respond_to
do
|
format
|
format
.
html
do
message
=
"User was successfully removed from
#{
source_type
}
."
redirect_to
members_page_url
,
notice:
message
end
format
.
js
{
head
:ok
}
end
end
def
request_access
membershipable
.
request_access
(
current_user
)
...
...
@@ -23,20 +37,20 @@ module MembershipActions
def
approve_access_request
Members
::
ApproveAccessRequestService
.
new
(
membershipable
,
current_user
,
params
).
execute
redirect_to
polymorphic_url
([
membershipable
,
:members
])
redirect_to
members_page_url
end
def
leave
member
=
Members
::
DestroyService
.
new
(
membershipable
,
current_user
,
user_id:
current_user
.
id
).
execute
(
:all
)
source_type
=
membershipable
.
class
.
to_s
.
humanize
(
capitalize:
false
)
notice
=
if
member
.
request?
"Your access request to the
#{
source_type
}
has been withdrawn."
else
"You left the
\"
#{
membershipable
.
human_name
}
\"
#{
source_type
}
."
end
redirect_path
=
member
.
request?
?
member
.
source
:
[
:dashboard
,
membershipable
.
class
.
to_s
.
tableize
]
redirect_to
redirect_path
,
notice:
notice
...
...
@@ -47,4 +61,16 @@ module MembershipActions
def
membershipable
raise
NotImplementedError
end
def
members_page_url
if
membershipable
.
is_a?
(
Project
)
project_settings_members_path
(
membershipable
)
else
polymorphic_url
([
membershipable
,
:members
])
end
end
def
source_type
@source_type
||=
membershipable
.
class
.
to_s
.
humanize
(
capitalize:
false
)
end
end
app/controllers/groups/group_members_controller.rb
View file @
395fca14
...
...
@@ -29,15 +29,6 @@ class Groups::GroupMembersController < Groups::ApplicationController
@group_member
.
update_attributes
(
member_params
)
end
def
destroy
Members
::
DestroyService
.
new
(
@group
,
current_user
,
id:
params
[
:id
]).
execute
(
:all
)
respond_to
do
|
format
|
format
.
html
{
redirect_to
group_group_members_path
(
@group
),
notice:
'User was successfully removed from group.'
}
format
.
js
{
head
:ok
}
end
end
def
resend_invite
redirect_path
=
group_group_members_path
(
@group
)
...
...
app/controllers/projects/project_members_controller.rb
View file @
395fca14
...
...
@@ -18,18 +18,6 @@ class Projects::ProjectMembersController < Projects::ApplicationController
@project_member
.
update_attributes
(
member_params
)
end
def
destroy
Members
::
DestroyService
.
new
(
@project
,
current_user
,
params
).
execute
(
:all
)
respond_to
do
|
format
|
format
.
html
do
redirect_to
namespace_project_settings_members_path
(
@project
.
namespace
,
@project
)
end
format
.
js
{
head
:ok
}
end
end
def
resend_invite
redirect_path
=
namespace_project_settings_members_path
(
@project
.
namespace
,
@project
)
...
...
spec/controllers/projects/project_members_controller_spec.rb
View file @
395fca14
...
...
@@ -225,7 +225,7 @@ describe Projects::ProjectMembersController do
id:
member
expect
(
response
).
to
redirect_to
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
)
expect
(
project
.
members
).
to
include
member
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