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
Tatuya Kamada
gitlab-ce
Commits
9b376e77
Commit
9b376e77
authored
Aug 25, 2016
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitHub importer use default project visibility for non-private projects
parent
e71cd7a3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
15 deletions
+41
-15
lib/gitlab/github_import/project_creator.rb
lib/gitlab/github_import/project_creator.rb
+1
-1
spec/lib/gitlab/github_import/project_creator_spec.rb
spec/lib/gitlab/github_import/project_creator_spec.rb
+40
-14
No files found.
lib/gitlab/github_import/project_creator.rb
View file @
9b376e77
...
@@ -17,7 +17,7 @@ module Gitlab
...
@@ -17,7 +17,7 @@ module Gitlab
path:
repo
.
name
,
path:
repo
.
name
,
description:
repo
.
description
,
description:
repo
.
description
,
namespace_id:
namespace
.
id
,
namespace_id:
namespace
.
id
,
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
Gitlab
::
VisibilityLevel
::
PUBLIC
,
visibility_level:
repo
.
private
?
Gitlab
::
VisibilityLevel
::
PRIVATE
:
ApplicationSetting
.
current
.
default_project_visibility
,
import_type:
"github"
,
import_type:
"github"
,
import_source:
repo
.
full_name
,
import_source:
repo
.
full_name
,
import_url:
repo
.
clone_url
.
sub
(
"https://"
,
"https://
#{
@session_data
[
:github_access_token
]
}
@"
),
import_url:
repo
.
clone_url
.
sub
(
"https://"
,
"https://
#{
@session_data
[
:github_access_token
]
}
@"
),
...
...
spec/lib/gitlab/github_import/project_creator_spec.rb
View file @
9b376e77
...
@@ -2,33 +2,59 @@ require 'spec_helper'
...
@@ -2,33 +2,59 @@ require 'spec_helper'
describe
Gitlab
::
GithubImport
::
ProjectCreator
,
lib:
true
do
describe
Gitlab
::
GithubImport
::
ProjectCreator
,
lib:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:namespace
)
{
create
(
:group
,
owner:
user
)
}
let
(
:repo
)
do
let
(
:repo
)
do
OpenStruct
.
new
(
OpenStruct
.
new
(
login:
'vim'
,
login:
'vim'
,
name:
'vim'
,
name:
'vim'
,
private:
true
,
full_name:
'asd/vim'
,
full_name:
'asd/vim'
,
clone_url:
"https://gitlab.com/asd/vim.git"
,
clone_url:
'https://gitlab.com/asd/vim.git'
owner:
OpenStruct
.
new
(
login:
"john"
)
)
)
end
end
let
(
:namespace
)
{
create
(
:group
,
owner:
user
)
}
let
(
:token
)
{
"asdffg"
}
subject
(
:service
)
{
described_class
.
new
(
repo
,
namespace
,
user
,
github_access_token:
'asdffg'
)
}
let
(
:access_params
)
{
{
github_access_token:
token
}
}
before
do
before
do
namespace
.
add_owner
(
user
)
namespace
.
add_owner
(
user
)
allow_any_instance_of
(
Project
).
to
receive
(
:add_import_job
)
end
end
it
'creates project'
do
describe
'#execute'
do
allow_any_instance_of
(
Project
).
to
receive
(
:add_import_job
)
it
'creates a project'
do
expect
{
service
.
execute
}.
to
change
(
Project
,
:count
).
by
(
1
)
end
it
'handle GitHub credentials'
do
project
=
service
.
execute
expect
(
project
.
import_url
).
to
eq
(
'https://asdffg@gitlab.com/asd/vim.git'
)
expect
(
project
.
safe_import_url
).
to
eq
(
'https://*****@gitlab.com/asd/vim.git'
)
expect
(
project
.
import_data
.
credentials
).
to
eq
(
user:
'asdffg'
,
password:
nil
)
end
context
'when Github project is private'
do
it
'sets project visibility to private'
do
repo
.
private
=
true
project
=
service
.
execute
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
context
'when Github project is public'
do
before
do
allow_any_instance_of
(
ApplicationSetting
).
to
receive
(
:default_project_visibility
).
and_return
(
Gitlab
::
VisibilityLevel
::
INTERNAL
)
end
it
'sets project visibility to the default project visibility'
do
repo
.
private
=
false
project_creator
=
Gitlab
::
GithubImport
::
ProjectCreator
.
new
(
repo
,
namespace
,
user
,
access_params
)
project
=
service
.
execute
project
=
project_creator
.
execute
expect
(
project
.
import_url
).
to
eq
(
"https://asdffg@gitlab.com/asd/vim.git"
)
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
INTERNAL
)
expect
(
project
.
safe_import_url
).
to
eq
(
"https://*****@gitlab.com/asd/vim.git"
)
end
expect
(
project
.
import_data
.
credentials
).
to
eq
(
user:
"asdffg"
,
password:
nil
)
end
expect
(
project
.
visibility_level
).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
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