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
79534806
Commit
79534806
authored
Nov 20, 2016
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix remaining Bitbucket controller specs
parent
af692628
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
15 deletions
+12
-15
app/controllers/import/bitbucket_controller.rb
app/controllers/import/bitbucket_controller.rb
+1
-1
spec/controllers/import/bitbucket_controller_spec.rb
spec/controllers/import/bitbucket_controller_spec.rb
+11
-14
No files found.
app/controllers/import/bitbucket_controller.rb
View file @
79534806
...
...
@@ -46,7 +46,7 @@ class Import::BitbucketController < Import::BaseController
repo_owner
=
current_user
.
username
if
repo_owner
==
bitbucket_client
.
user
.
username
@target_namespace
=
params
[
:new_namespace
].
presence
||
repo_owner
namespace
=
find_or_create_namespace
(
@target_namespace
,
repo_own
er
)
namespace
=
find_or_create_namespace
(
@target_namespace
,
current_us
er
)
if
current_user
.
can?
(
:create_projects
,
namespace
)
@project
=
Gitlab
::
BitbucketImport
::
ProjectCreator
.
new
(
repo
,
@project_name
,
namespace
,
current_user
,
credentials
).
execute
...
...
spec/controllers/import/bitbucket_controller_spec.rb
View file @
79534806
...
...
@@ -7,7 +7,7 @@ describe Import::BitbucketController do
let
(
:token
)
{
"asdasd12345"
}
let
(
:secret
)
{
"sekrettt"
}
let
(
:refresh_token
)
{
SecureRandom
.
hex
(
15
)
}
let
(
:access_params
)
{
{
bitbucket_access_token:
token
,
bitbucket_access_token_secret:
secret
}
}
let
(
:access_params
)
{
{
token:
token
,
expires_at:
nil
,
expires_in:
nil
,
refresh_token:
nil
}
}
def
assign_session_tokens
session
[
:bitbucket_token
]
=
token
...
...
@@ -77,19 +77,16 @@ describe Import::BitbucketController do
let
(
:bitbucket_username
)
{
user
.
username
}
let
(
:bitbucket_user
)
do
{
user:
{
username:
bitbucket_username
}
}.
with_indifferent_access
double
(
username:
bitbucket_username
)
end
let
(
:bitbucket_repo
)
do
{
slug:
"vim"
,
owner:
bitbucket_username
}.
with_indifferent_access
double
(
slug:
"vim"
,
owner:
bitbucket_username
,
name:
'vim'
)
end
before
do
allow
(
Gitlab
::
BitbucketImport
::
KeyAdder
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
user
,
access_params
).
and_return
(
double
(
execute:
true
))
stub_client
(
user:
bitbucket_user
,
project:
bitbucket_repo
)
allow_any_instance_of
(
Bitbucket
::
Client
).
to
receive
(
:repo
).
and_return
(
bitbucket_repo
)
allow_any_instance_of
(
Bitbucket
::
Client
).
to
receive
(
:user
).
and_return
(
bitbucket_user
)
assign_session_tokens
end
...
...
@@ -97,7 +94,7 @@ describe Import::BitbucketController do
context
"when the Bitbucket user and GitLab user's usernames match"
do
it
"takes the current user's namespace"
do
expect
(
Gitlab
::
BitbucketImport
::
ProjectCreator
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
user
.
namespace
,
user
,
access_params
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
bitbucket_repo
.
name
,
user
.
namespace
,
user
,
access_params
).
and_return
(
double
(
execute:
true
))
post
:create
,
format: :js
...
...
@@ -109,7 +106,7 @@ describe Import::BitbucketController do
it
"takes the current user's namespace"
do
expect
(
Gitlab
::
BitbucketImport
::
ProjectCreator
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
user
.
namespace
,
user
,
access_params
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
bitbucket_repo
.
name
,
user
.
namespace
,
user
,
access_params
).
and_return
(
double
(
execute:
true
))
post
:create
,
format: :js
...
...
@@ -121,7 +118,7 @@ describe Import::BitbucketController do
let
(
:other_username
)
{
"someone_else"
}
before
do
bitbucket_repo
[
"owner"
]
=
other_username
allow
(
bitbucket_repo
).
to
receive
(
:owner
).
and_return
(
other_username
)
end
context
"when a namespace with the Bitbucket user's username already exists"
do
...
...
@@ -130,7 +127,7 @@ describe Import::BitbucketController do
context
"when the namespace is owned by the GitLab user"
do
it
"takes the existing namespace"
do
expect
(
Gitlab
::
BitbucketImport
::
ProjectCreator
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
existing_namespace
,
user
,
access_params
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
bitbucket_repo
.
name
,
existing_namespace
,
user
,
access_params
).
and_return
(
double
(
execute:
true
))
post
:create
,
format: :js
...
...
@@ -163,7 +160,7 @@ describe Import::BitbucketController do
it
"takes the new namespace"
do
expect
(
Gitlab
::
BitbucketImport
::
ProjectCreator
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
an_instance_of
(
Group
),
user
,
access_params
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
bitbucket_repo
.
name
,
an_instance_of
(
Group
),
user
,
access_params
).
and_return
(
double
(
execute:
true
))
post
:create
,
format: :js
...
...
@@ -184,7 +181,7 @@ describe Import::BitbucketController do
it
"takes the current user's namespace"
do
expect
(
Gitlab
::
BitbucketImport
::
ProjectCreator
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
user
.
namespace
,
user
,
access_params
).
to
receive
(
:new
).
with
(
bitbucket_repo
,
bitbucket_repo
.
name
,
user
.
namespace
,
user
,
access_params
).
and_return
(
double
(
execute:
true
))
post
:create
,
format: :js
...
...
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