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
3d3ac87a
Commit
3d3ac87a
authored
Feb 17, 2016
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redirect /import to project page if no importing at all and repo exists
Fixes #13367.
parent
943bed68
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
3 deletions
+25
-3
app/controllers/projects/imports_controller.rb
app/controllers/projects/imports_controller.rb
+9
-3
app/models/project.rb
app/models/project.rb
+4
-0
spec/controllers/projects/imports_controller_spec.rb
spec/controllers/projects/imports_controller_spec.rb
+12
-0
No files found.
app/controllers/projects/imports_controller.rb
View file @
3d3ac87a
...
@@ -3,6 +3,7 @@ class Projects::ImportsController < Projects::ApplicationController
...
@@ -3,6 +3,7 @@ class Projects::ImportsController < Projects::ApplicationController
before_action
:authorize_admin_project!
before_action
:authorize_admin_project!
before_action
:require_no_repo
,
only:
[
:new
,
:create
]
before_action
:require_no_repo
,
only:
[
:new
,
:create
]
before_action
:redirect_if_progress
,
only:
[
:new
,
:create
]
before_action
:redirect_if_progress
,
only:
[
:new
,
:create
]
before_action
:redirect_if_no_import
,
only: :show
def
new
def
new
end
end
...
@@ -63,14 +64,19 @@ class Projects::ImportsController < Projects::ApplicationController
...
@@ -63,14 +64,19 @@ class Projects::ImportsController < Projects::ApplicationController
def
require_no_repo
def
require_no_repo
if
@project
.
repository_exists?
if
@project
.
repository_exists?
redirect_to
(
namespace_project_path
(
@project
.
namespace
,
@project
)
)
redirect_to
namespace_project_path
(
@project
.
namespace
,
@project
)
end
end
end
end
def
redirect_if_progress
def
redirect_if_progress
if
@project
.
import_in_progress?
if
@project
.
import_in_progress?
redirect_to
namespace_project_import_path
(
@project
.
namespace
,
@project
)
&&
redirect_to
namespace_project_import_path
(
@project
.
namespace
,
@project
)
return
end
end
def
redirect_if_no_import
if
@project
.
repository_exists?
&&
@project
.
no_import?
redirect_to
namespace_project_path
(
@project
.
namespace
,
@project
)
end
end
end
end
end
end
app/models/project.rb
View file @
3d3ac87a
...
@@ -382,6 +382,10 @@ class Project < ActiveRecord::Base
...
@@ -382,6 +382,10 @@ class Project < ActiveRecord::Base
external_import?
||
forked?
external_import?
||
forked?
end
end
def
no_import?
import_status
==
'none'
end
def
external_import?
def
external_import?
import_url
.
present?
import_url
.
present?
end
end
...
...
spec/controllers/projects/imports_controller_spec.rb
View file @
3d3ac87a
...
@@ -104,6 +104,18 @@ describe Projects::ImportsController do
...
@@ -104,6 +104,18 @@ describe Projects::ImportsController do
end
end
end
end
end
end
context
'when import never happened'
do
before
do
project
.
update_attribute
(
:import_status
,
:none
)
end
it
'redirects to namespace_project_path'
do
get
:show
,
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
.
to_param
expect
(
response
).
to
redirect_to
namespace_project_path
(
project
.
namespace
,
project
)
end
end
end
end
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