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
Léo-Paul Géneau
gitlab-ce
Commits
b9b0b37b
Commit
b9b0b37b
authored
Aug 30, 2017
by
Rubén Dávila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add check for access to Namespace
parent
6f03ddcd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
3 deletions
+38
-3
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+4
-1
app/helpers/namespaces_helper.rb
app/helpers/namespaces_helper.rb
+2
-2
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+32
-0
No files found.
app/controllers/projects_controller.rb
View file @
b9b0b37b
...
...
@@ -20,7 +20,10 @@ class ProjectsController < Projects::ApplicationController
end
def
new
@project
||=
Project
.
new
(
params
.
permit
(
:namespace_id
))
namespace
=
Namespace
.
find_by
(
id:
params
[
:namespace_id
])
if
params
[
:namespace_id
]
return
access_denied!
if
namespace
&&
!
can?
(
current_user
,
:create_projects
,
namespace
)
@project
=
Project
.
new
(
namespace_id:
namespace
&
.
id
)
end
def
edit
...
...
app/helpers/namespaces_helper.rb
View file @
b9b0b37b
...
...
@@ -45,8 +45,8 @@ module NamespacesHelper
visibility_level:
n
.
visibility_level_value
,
visibility:
n
.
visibility
,
name:
n
.
name
,
show_path:
n
.
is_a?
(
Group
)
?
group_path
(
n
)
:
user_path
(
n
),
edit_path:
n
.
is_a?
(
Group
)
?
edit_group_path
(
n
)
:
nil
show_path:
(
type
==
'group'
)
?
group_path
(
n
)
:
user_path
(
n
),
edit_path:
(
type
==
'group'
)
?
edit_group_path
(
n
)
:
nil
}]
end
...
...
spec/controllers/projects_controller_spec.rb
View file @
b9b0b37b
...
...
@@ -7,6 +7,38 @@ describe ProjectsController do
let
(
:jpg
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
}
let
(
:txt
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
describe
'GET new'
do
context
'with an authenticated user'
do
let
(
:group
)
{
create
(
:group
)
}
before
do
sign_in
(
user
)
end
context
'when namespace_id param is present'
do
context
'when user has access to the namespace'
do
it
'renders the template'
do
group
.
add_owner
(
user
)
get
:new
,
namespace_id:
group
.
id
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
render_template
(
'new'
)
end
end
context
'when user does not have access to the namespace'
do
it
'responds with status 404'
do
get
:new
,
namespace_id:
group
.
id
expect
(
response
).
to
have_http_status
(
404
)
expect
(
response
).
not_to
render_template
(
'new'
)
end
end
end
end
end
describe
'GET index'
do
context
'as a user'
do
it
'redirects to root page'
do
...
...
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