diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-01-22 16:08:15 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2019-01-22 16:08:15 +0300 |
commit | 5e933a4d684d41220ad0177843de1c3692cf585f (patch) | |
tree | 7388a1e8be71781b38392fa6899c9094f89f9230 /spec | |
parent | ed1da730202bf3178c43b3467635853733b799c1 (diff) | |
parent | f13edec8c7f568f32da9e516888ed229c8963051 (diff) |
Merge branch '53671-redirect-projects-id-to-project-page' into 'master'
Resolve "Redirect projects/:id to project page"
Closes #53671
See merge request gitlab-org/gitlab-ce!24467
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects_controller_spec.rb | 53 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 4 |
2 files changed, 57 insertions, 0 deletions
diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index f84f069f4db..9801ed19957 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -955,6 +955,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 diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 5c3b37ef11c..a0d01fc8263 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -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 |