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
iv
gitlab-ce
Commits
d75edf1a
Commit
d75edf1a
authored
Jun 01, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize access request routes into a new :access_requestable route concern
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
d71fbe0d
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
19 deletions
+10
-19
app/controllers/concerns/access_request_actions.rb
app/controllers/concerns/access_request_actions.rb
+1
-1
app/helpers/members_helper.rb
app/helpers/members_helper.rb
+2
-2
config/routes.rb
config/routes.rb
+5
-14
spec/helpers/members_helper_spec.rb
spec/helpers/members_helper_spec.rb
+2
-2
No files found.
app/controllers/concerns/access_request_actions.rb
View file @
d75edf1a
...
@@ -8,7 +8,7 @@ module AccessRequestActions
...
@@ -8,7 +8,7 @@ module AccessRequestActions
notice:
'Your request for access has been queued for review.'
notice:
'Your request for access has been queued for review.'
end
end
def
approve
def
approve
_access_request
@member
=
access_requestable_resource
.
public_send
(
member_entity_name
.
pluralize
).
request
.
find
(
params
[
:id
])
@member
=
access_requestable_resource
.
public_send
(
member_entity_name
.
pluralize
).
request
.
find
(
params
[
:id
])
return
render_403
unless
can?
(
current_user
,
:"update_
#{
member_entity_name
}
"
,
@member
)
return
render_403
unless
can?
(
current_user
,
:"update_
#{
member_entity_name
}
"
,
@member
)
...
...
app/helpers/members_helper.rb
View file @
d75edf1a
...
@@ -53,9 +53,9 @@ module MembersHelper
...
@@ -53,9 +53,9 @@ module MembersHelper
def
approve_request_member_path
(
member
)
def
approve_request_member_path
(
member
)
case
member
.
source
case
member
.
source
when
Project
when
Project
approve_namespace_project_project_member_path
(
member
.
source
.
namespace
,
member
.
source
,
member
)
approve_
access_request_
namespace_project_project_member_path
(
member
.
source
.
namespace
,
member
.
source
,
member
)
when
Group
when
Group
approve_group_group_member_path
(
member
.
source
,
member
)
approve_
access_request_
group_group_member_path
(
member
.
source
,
member
)
else
else
raise
ArgumentError
.
new
(
'Unknown object class'
)
raise
ArgumentError
.
new
(
'Unknown object class'
)
end
end
...
...
config/routes.rb
View file @
d75edf1a
...
@@ -32,7 +32,7 @@ Rails.application.routes.draw do
...
@@ -32,7 +32,7 @@ Rails.application.routes.draw do
concern
:access_requestable
do
concern
:access_requestable
do
post
:request_access
,
on: :collection
post
:request_access
,
on: :collection
post
:approve_access_request
_access_request
,
on: :member
post
:approve_access_request
,
on: :member
end
end
namespace
:ci
do
namespace
:ci
do
...
@@ -414,16 +414,9 @@ Rails.application.routes.draw do
...
@@ -414,16 +414,9 @@ Rails.application.routes.draw do
end
end
scope
module: :groups
do
scope
module: :groups
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
]
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
concerns: :access_requestable
do
collection
do
post
:resend_invite
,
on: :member
delete
:leave
delete
:leave
,
on: :collection
post
:request_access
end
member
do
post
:resend_invite
post
:approve
end
end
end
resource
:avatar
,
only:
[
:destroy
]
resource
:avatar
,
only:
[
:destroy
]
...
@@ -777,10 +770,9 @@ Rails.application.routes.draw do
...
@@ -777,10 +770,9 @@ Rails.application.routes.draw do
end
end
end
end
resources
:project_members
,
except:
[
:new
,
:edit
],
constraints:
{
id:
/[a-zA-Z.\/0-9_\-#%+]+/
}
do
resources
:project_members
,
except:
[
:new
,
:edit
],
constraints:
{
id:
/[a-zA-Z.\/0-9_\-#%+]+/
}
,
concerns: :access_requestable
do
collection
do
collection
do
delete
:leave
delete
:leave
post
:request_access
# Used for import team
# Used for import team
# from another project
# from another project
...
@@ -790,7 +782,6 @@ Rails.application.routes.draw do
...
@@ -790,7 +782,6 @@ Rails.application.routes.draw do
member
do
member
do
post
:resend_invite
post
:resend_invite
post
:approve
end
end
end
end
...
...
spec/helpers/members_helper_spec.rb
View file @
d75edf1a
...
@@ -72,8 +72,8 @@ describe MembersHelper do
...
@@ -72,8 +72,8 @@ describe MembersHelper do
let
(
:project_member
)
{
create
(
:project_member
)
}
let
(
:project_member
)
{
create
(
:project_member
)
}
let
(
:group_member
)
{
create
(
:group_member
)
}
let
(
:group_member
)
{
create
(
:group_member
)
}
it
{
expect
(
approve_request_member_path
(
project_member
)).
to
eq
approve_namespace_project_project_member_path
(
project_member
.
source
.
namespace
,
project_member
.
source
,
project_member
)
}
it
{
expect
(
approve_request_member_path
(
project_member
)).
to
eq
approve_
access_request_
namespace_project_project_member_path
(
project_member
.
source
.
namespace
,
project_member
.
source
,
project_member
)
}
it
{
expect
(
approve_request_member_path
(
group_member
)).
to
eq
approve_group_group_member_path
(
group_member
.
source
,
group_member
)
}
it
{
expect
(
approve_request_member_path
(
group_member
)).
to
eq
approve_
access_request_
group_group_member_path
(
group_member
.
source
,
group_member
)
}
it
{
expect
{
approve_request_member_path
(
double
(
:member
,
source:
'foo'
))
}.
to
raise_error
ArgumentError
,
'Unknown object class'
}
it
{
expect
{
approve_request_member_path
(
double
(
:member
,
source:
'foo'
))
}.
to
raise_error
ArgumentError
,
'Unknown object class'
}
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