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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
02b5df78
Commit
02b5df78
authored
Jan 22, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
456e8019
5e933a4d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
84 additions
and
3 deletions
+84
-3
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+13
-3
changelogs/unreleased/53671-redirect-projects-id-to-project-page.yml
...unreleased/53671-redirect-projects-id-to-project-page.yml
+5
-0
config/routes/project.rb
config/routes/project.rb
+2
-0
doc/user/project/index.md
doc/user/project/index.md
+7
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+53
-0
spec/routing/project_routing_spec.rb
spec/routing/project_routing_spec.rb
+4
-0
No files found.
app/controllers/projects_controller.rb
View file @
02b5df78
...
...
@@ -10,10 +10,10 @@ class ProjectsController < Projects::ApplicationController
prepend_before_action
(
only:
[
:show
])
{
authenticate_sessionless_user!
(
:rss
)
}
before_action
:whitelist_query_limiting
,
only:
[
:create
]
before_action
:authenticate_user!
,
except:
[
:index
,
:show
,
:activity
,
:refs
]
before_action
:authenticate_user!
,
except:
[
:index
,
:show
,
:activity
,
:refs
,
:resolve
]
before_action
:redirect_git_extension
,
only:
[
:show
]
before_action
:project
,
except:
[
:index
,
:new
,
:create
]
before_action
:repository
,
except:
[
:index
,
:new
,
:create
]
before_action
:project
,
except:
[
:index
,
:new
,
:create
,
:resolve
]
before_action
:repository
,
except:
[
:index
,
:new
,
:create
,
:resolve
]
before_action
:assign_ref_vars
,
only:
[
:show
],
if: :repo_exists?
before_action
:tree
,
only:
[
:show
],
if:
[
:repo_exists?
,
:project_view_files?
]
before_action
:lfs_blob_ids
,
only:
[
:show
],
if:
[
:repo_exists?
,
:project_view_files?
]
...
...
@@ -442,6 +442,16 @@ class ProjectsController < Projects::ApplicationController
def
present_project
@project
=
@project
.
present
(
current_user:
current_user
)
end
def
resolve
@project
=
Project
.
find
(
params
[
:id
])
if
can?
(
current_user
,
:read_project
,
@project
)
redirect_to
@project
else
render_404
end
end
end
ProjectsController
.
prepend
(
EE
::
ProjectsController
)
changelogs/unreleased/53671-redirect-projects-id-to-project-page.yml
0 → 100644
View file @
02b5df78
---
title
:
Redirect GET projects/:id to project page
merge_request
:
24467
author
:
type
:
added
config/routes/project.rb
View file @
02b5df78
...
...
@@ -2,6 +2,8 @@ resources :projects, only: [:index, :new, :create]
draw
:git_http
get
'/projects/:id'
=>
'projects#resolve'
constraints
(
::
Constraints
::
ProjectUrlConstrainer
.
new
)
do
# If the route has a wildcard segment, the segment has a regex constraint,
# the segment is potentially followed by _another_ wildcard segment, and
...
...
doc/user/project/index.md
View file @
02b5df78
...
...
@@ -184,3 +184,10 @@ machine example.gitlab.com
login <gitlab_user_name>
password <personal_access_token>
```
## Access project page with project ID
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/53671) in GitLab 11.8.
To quickly access a project from the GitLab UI using the project ID,
visit the
`/projects/:id`
URL in your browser or other tool accessing the project.
spec/controllers/projects_controller_spec.rb
View file @
02b5df78
...
...
@@ -1004,6 +1004,59 @@ describe ProjectsController do
end
end
describe
'GET resolve'
do
shared_examples
'resolvable endpoint'
do
it
'redirects to the project page'
do
get
:resolve
,
params:
{
id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
302
)
expect
(
response
).
to
redirect_to
(
project_path
(
project
))
end
end
context
'with an authenticated user'
do
before
do
sign_in
(
user
)
end
context
'when user has access to the project'
do
before
do
project
.
add_developer
(
user
)
end
it_behaves_like
'resolvable endpoint'
end
context
'when user has no access to the project'
do
it
'gives 404 for existing project'
do
get
:resolve
,
params:
{
id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
it
'gives 404 for non-existing project'
do
get
:resolve
,
params:
{
id:
'0'
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
context
'non authenticated user'
do
context
'with a public project'
do
let
(
:project
)
{
public_project
}
it_behaves_like
'resolvable endpoint'
end
it
'gives 404 for private project'
do
get
:resolve
,
params:
{
id:
project
.
id
}
expect
(
response
).
to
have_gitlab_http_status
(
404
)
end
end
end
def
project_moved_message
(
redirect_route
,
project
)
"Project '
#{
redirect_route
.
path
}
' was moved to '
#{
project
.
full_path
}
'. Please update any links and bookmarks that may still have the old path."
end
...
...
spec/routing/project_routing_spec.rb
View file @
02b5df78
...
...
@@ -122,6 +122,10 @@ describe 'project routing' do
route_to
(
'projects#preview_markdown'
,
namespace_id:
'gitlab'
,
id:
'gitlabhq'
)
)
end
it
'to #resolve'
do
expect
(
get
(
'/projects/1'
)).
to
route_to
(
'projects#resolve'
,
id:
'1'
)
end
end
# members_namespace_project_autocomplete_sources_path GET /:project_id/autocomplete_sources/members(.:format) projects/autocomplete_sources#members
...
...
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