BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
30f9596c
Commit
30f9596c
authored
Aug 11, 2016
by
James Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix permissions check in controller, added relevant spec and updated docs
parent
34d5426f
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
9 deletions
+34
-9
gitlab_projects_controller.rb
app/controllers/import/gitlab_projects_controller.rb
+5
-0
new.html.haml
app/views/projects/new.html.haml
+1
-1
import_export.md
doc/user/project/settings/import_export.md
+1
-2
new_project.feature
features/dashboard/new_project.feature
+1
-1
new_project.rb
features/steps/dashboard/new_project.rb
+1
-2
import_file_spec.rb
spec/features/projects/import_export/import_file_spec.rb
+25
-3
No files found.
app/controllers/import/gitlab_projects_controller.rb
View file @
30f9596c
class
Import
::
GitlabProjectsController
<
Import
::
BaseController
class
Import
::
GitlabProjectsController
<
Import
::
BaseController
before_action
:verify_gitlab_project_import_enabled
before_action
:verify_gitlab_project_import_enabled
before_action
:authenticate_admin!
def
new
def
new
@namespace_id
=
project_params
[
:namespace_id
]
@namespace_id
=
project_params
[
:namespace_id
]
...
@@ -47,4 +48,8 @@ class Import::GitlabProjectsController < Import::BaseController
...
@@ -47,4 +48,8 @@ class Import::GitlabProjectsController < Import::BaseController
:path
,
:namespace_id
,
:file
:path
,
:namespace_id
,
:file
)
)
end
end
def
authenticate_admin!
render_404
unless
current_user
.
is_admin?
end
end
end
app/views/projects/new.html.haml
View file @
30f9596c
...
@@ -77,7 +77,7 @@
...
@@ -77,7 +77,7 @@
=
link_to
"#"
,
class:
'btn js-toggle-button import_git'
do
=
link_to
"#"
,
class:
'btn js-toggle-button import_git'
do
=
icon
(
'git'
,
text:
'Repo by URL'
)
=
icon
(
'git'
,
text:
'Repo by URL'
)
%div
{
class:
'import_gitlab_project'
}
%div
{
class:
'import_gitlab_project'
}
-
if
gitlab_project_import_enabled?
-
if
gitlab_project_import_enabled?
&&
current_user
.
is_admin?
=
link_to
new_import_gitlab_project_path
,
class:
'btn btn_import_gitlab_project project-submit'
do
=
link_to
new_import_gitlab_project_path
,
class:
'btn btn_import_gitlab_project project-submit'
do
=
icon
(
'gitlab'
,
text:
'GitLab export'
)
=
icon
(
'gitlab'
,
text:
'GitLab export'
)
...
...
doc/user/project/settings/import_export.md
View file @
30f9596c
...
@@ -7,8 +7,7 @@
...
@@ -7,8 +7,7 @@
> than that of the exporter.
> than that of the exporter.
> - For existing installations, the project import option has to be enabled in
> - For existing installations, the project import option has to be enabled in
> application settings (`/admin/application_settings`) under 'Import sources'.
> application settings (`/admin/application_settings`) under 'Import sources'.
> Ask your administrator if you don't see the **GitLab export** button when
> You will have to be an administrator to enable and use the import functionality.
> creating a new project.
> - You can find some useful raketasks if you are an administrator in the
> - You can find some useful raketasks if you are an administrator in the
> [import_export](../../../administration/raketasks/project_import_export.md)
> [import_export](../../../administration/raketasks/project_import_export.md)
> raketask.
> raketask.
...
...
features/dashboard/new_project.feature
View file @
30f9596c
...
@@ -9,7 +9,7 @@ Background:
...
@@ -9,7 +9,7 @@ Background:
@javascript
@javascript
Scenario
:
I
should see New Projects page
Scenario
:
I
should see New Projects page
Then
I see
"New Project"
page
Then
I see
"New Project"
page
Then
I see all possible import optios
Then
I see all possible import optio
n
s
@javascript
@javascript
Scenario
:
I
should see instructions on how to import from Git URL
Scenario
:
I
should see instructions on how to import from Git URL
...
...
features/steps/dashboard/new_project.rb
View file @
30f9596c
...
@@ -14,14 +14,13 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
...
@@ -14,14 +14,13 @@ class Spinach::Features::NewProject < Spinach::FeatureSteps
expect
(
page
).
to
have_content
(
'Project name'
)
expect
(
page
).
to
have_content
(
'Project name'
)
end
end
step
'I see all possible import optios'
do
step
'I see all possible import optio
n
s'
do
expect
(
page
).
to
have_link
(
'GitHub'
)
expect
(
page
).
to
have_link
(
'GitHub'
)
expect
(
page
).
to
have_link
(
'Bitbucket'
)
expect
(
page
).
to
have_link
(
'Bitbucket'
)
expect
(
page
).
to
have_link
(
'GitLab.com'
)
expect
(
page
).
to
have_link
(
'GitLab.com'
)
expect
(
page
).
to
have_link
(
'Gitorious.org'
)
expect
(
page
).
to
have_link
(
'Gitorious.org'
)
expect
(
page
).
to
have_link
(
'Google Code'
)
expect
(
page
).
to
have_link
(
'Google Code'
)
expect
(
page
).
to
have_link
(
'Repo by URL'
)
expect
(
page
).
to
have_link
(
'Repo by URL'
)
expect
(
page
).
to
have_link
(
'GitLab export'
)
end
end
step
'I click on "Import project from GitHub"'
do
step
'I click on "Import project from GitHub"'
do
...
...
spec/features/projects/import_export/import_file_spec.rb
View file @
30f9596c
...
@@ -3,8 +3,9 @@ require 'spec_helper'
...
@@ -3,8 +3,9 @@ require 'spec_helper'
feature
'project import'
,
feature:
true
,
js:
true
do
feature
'project import'
,
feature:
true
,
js:
true
do
include
Select2Helper
include
Select2Helper
let
(
:user
)
{
create
(
:admin
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
"asd"
,
owner:
user
)
}
let
(
:normal_user
)
{
create
(
:user
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
"asd"
,
owner:
admin
)
}
let
(
:file
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'features'
,
'projects'
,
'import_export'
,
'test_project_export.tar.gz'
)
}
let
(
:file
)
{
File
.
join
(
Rails
.
root
,
'spec'
,
'features'
,
'projects'
,
'import_export'
,
'test_project_export.tar.gz'
)
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/import_file_spec"
}
let
(
:export_path
)
{
"
#{
Dir
::
tmpdir
}
/import_file_spec"
}
let
(
:project
)
{
Project
.
last
}
let
(
:project
)
{
Project
.
last
}
...
@@ -12,13 +13,17 @@ feature 'project import', feature: true, js: true do
...
@@ -12,13 +13,17 @@ feature 'project import', feature: true, js: true do
background
do
background
do
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
allow_any_instance_of
(
Gitlab
::
ImportExport
).
to
receive
(
:storage_path
).
and_return
(
export_path
)
login_as
(
user
)
end
end
after
(
:each
)
do
after
(
:each
)
do
FileUtils
.
rm_rf
(
export_path
,
secure:
true
)
FileUtils
.
rm_rf
(
export_path
,
secure:
true
)
end
end
context
'admin user'
do
before
do
login_as
(
admin
)
end
scenario
'user imports an exported project successfully'
do
scenario
'user imports an exported project successfully'
do
expect
(
Project
.
all
.
count
).
to
be_zero
expect
(
Project
.
all
.
count
).
to
be_zero
...
@@ -74,6 +79,23 @@ feature 'project import', feature: true, js: true do
...
@@ -74,6 +79,23 @@ feature 'project import', feature: true, js: true do
expect
(
page
).
to
have_content
(
'Please enter path and name'
)
expect
(
page
).
to
have_content
(
'Please enter path and name'
)
end
end
end
end
end
context
'normal user'
do
before
do
login_as
(
normal_user
)
end
scenario
'non-admin user is not allowed to import a project'
do
expect
(
Project
.
all
.
count
).
to
be_zero
visit
new_project_path
fill_in
:project_path
,
with:
'test-project-path'
,
visible:
true
expect
(
page
).
not_to
have_content
(
'GitLab export'
)
end
end
def
wiki_exists?
def
wiki_exists?
wiki
=
ProjectWiki
.
new
(
project
)
wiki
=
ProjectWiki
.
new
(
project
)
...
...
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