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
f2e38681
Commit
f2e38681
authored
Apr 18, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check permissions when sharing project with group
Closes #15330
parent
f1907ffd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
4 deletions
+60
-4
app/controllers/projects/group_links_controller.rb
app/controllers/projects/group_links_controller.rb
+10
-4
spec/controllers/projects/group_links_controller_spec.rb
spec/controllers/projects/group_links_controller_spec.rb
+50
-0
No files found.
app/controllers/projects/group_links_controller.rb
View file @
f2e38681
...
@@ -7,10 +7,16 @@ class Projects::GroupLinksController < Projects::ApplicationController
...
@@ -7,10 +7,16 @@ class Projects::GroupLinksController < Projects::ApplicationController
end
end
def
create
def
create
link
=
project
.
project_group_links
.
new
group
=
Group
.
find
(
params
[
:link_group_id
])
link
.
group_id
=
params
[
:link_group_id
]
link
.
group_access
=
params
[
:link_group_access
]
if
can?
(
current_user
,
:read_group
,
group
)
link
.
save
link
=
project
.
project_group_links
.
new
link
.
group_id
=
params
[
:link_group_id
]
link
.
group_access
=
params
[
:link_group_access
]
link
.
save
else
return
render_404
end
redirect_to
namespace_project_group_links_path
(
project
.
namespace
,
project
)
redirect_to
namespace_project_group_links_path
(
project
.
namespace
,
project
)
end
end
...
...
spec/controllers/projects/group_links_controller_spec.rb
0 → 100644
View file @
f2e38681
require
'spec_helper'
describe
Projects
::
GroupLinksController
do
let
(
:project
)
{
create
(
:project
,
:private
)
}
let
(
:group
)
{
create
(
:group
,
:private
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
team
<<
[
user
,
:master
]
sign_in
(
user
)
end
describe
'#create'
do
shared_context
'link project to group'
do
before
do
post
(
:create
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
,
link_group_id:
group
.
id
,
link_group_access:
ProjectGroupLink
.
default_access
)
end
end
context
'when user has access to group he want to link project to'
do
before
{
group
.
add_developer
(
user
)
}
include_context
'link project to group'
it
'links project with selected group'
do
expect
(
group
.
shared_projects
).
to
include
project
end
it
'redirects to project group links page'
do
expect
(
response
).
to
redirect_to
(
namespace_project_group_links_path
(
project
.
namespace
,
project
)
)
end
end
context
'when user doers not have access to group he want to link to'
do
include_context
'link project to group'
it
'renders 404'
do
expect
(
response
.
status
).
to
eq
404
end
it
'does not share project with that group'
do
expect
(
group
.
shared_projects
).
to_not
include
project
end
end
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