Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
fd69fee57d1e
Commit
fd69fee5
authored
Feb 17, 2016
by
Rémy Coutable
Browse files
Redirect /import to project page if no importing at all and repo exists
Fixes #13367.
parent
bcec7ed6ced5
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/controllers/projects/imports_controller.rb
View file @
fd69fee5
...
...
@@ -3,6 +3,7 @@
before_action
:authorize_admin_project!
before_action
:require_no_repo
,
only:
[
:new
,
:create
]
before_action
:redirect_if_progress
,
only:
[
:new
,
:create
]
before_action
:redirect_if_no_import
,
only: :show
def
new
end
...
...
@@ -63,9 +64,9 @@
def
require_no_repo
if
@project
.
repository_exists?
redirect_to
(
namespace_project_path
(
@project
.
namespace
,
@project
)
)
redirect_to
namespace_project_path
(
@project
.
namespace
,
@project
)
end
end
def
redirect_if_progress
if
@project
.
import_in_progress?
...
...
@@ -67,10 +68,15 @@
end
end
def
redirect_if_progress
if
@project
.
import_in_progress?
redirect_to
namespace_project_import_path
(
@project
.
namespace
,
@project
)
&&
return
redirect_to
namespace_project_import_path
(
@project
.
namespace
,
@project
)
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
app/models/project.rb
View file @
fd69fee5
...
...
@@ -382,6 +382,10 @@
external_import?
||
forked?
end
def
no_import?
import_status
==
'none'
end
def
external_import?
import_url
.
present?
end
...
...
spec/controllers/projects/imports_controller_spec.rb
View file @
fd69fee5
...
...
@@ -104,6 +104,18 @@
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
Write
Preview
Supports
Markdown
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