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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
57b914cc
Commit
57b914cc
authored
Jun 15, 2020
by
Illya Klymov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for invalid repos
parent
88b7e697
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
2 deletions
+41
-2
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
+21
-0
spec/controllers/import/bitbucket_server_controller_spec.rb
spec/controllers/import/bitbucket_server_controller_spec.rb
+19
-1
No files found.
app/controllers/import/bitbucket_controller.rb
View file @
57b914cc
...
@@ -82,7 +82,7 @@ class Import::BitbucketController < Import::BaseController
...
@@ -82,7 +82,7 @@ class Import::BitbucketController < Import::BaseController
def
importable_repos
def
importable_repos
already_added_projects_names
=
already_added_projects
.
map
(
&
:import_source
)
already_added_projects_names
=
already_added_projects
.
map
(
&
:import_source
)
bitbucket_repos
.
reject
{
|
repo
|
(
already_added_projects_names
.
include?
repo
.
full_name
)
||
!
repo
.
valid?
}
bitbucket_repos
.
reject
{
|
repo
|
already_added_projects_names
.
include?
(
repo
.
full_name
)
||
!
repo
.
valid?
}
end
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: enable CodeReuse/ActiveRecord
...
...
spec/controllers/import/bitbucket_controller_spec.rb
View file @
57b914cc
...
@@ -57,6 +57,8 @@ RSpec.describe Import::BitbucketController do
...
@@ -57,6 +57,8 @@ RSpec.describe Import::BitbucketController do
describe
"GET status"
do
describe
"GET status"
do
before
do
before
do
@repo
=
double
(
name:
'vim'
,
slug:
'vim'
,
owner:
'asd'
,
full_name:
'asd/vim'
,
clone_url:
'http://test.host/demo/url.git'
,
'valid?'
=>
true
)
@repo
=
double
(
name:
'vim'
,
slug:
'vim'
,
owner:
'asd'
,
full_name:
'asd/vim'
,
clone_url:
'http://test.host/demo/url.git'
,
'valid?'
=>
true
)
@invalid_repo
=
double
(
name:
'mercurialrepo'
,
slug:
'mercurialrepo'
,
owner:
'asd'
,
full_name:
'asd/mercurialrepo'
,
clone_url:
'http://test.host/demo/mercurialrepo.git'
,
'valid?'
=>
false
)
assign_session_tokens
assign_session_tokens
stub_feature_flags
(
new_import_ui:
false
)
stub_feature_flags
(
new_import_ui:
false
)
end
end
...
@@ -73,6 +75,25 @@ RSpec.describe Import::BitbucketController do
...
@@ -73,6 +75,25 @@ RSpec.describe Import::BitbucketController do
let
(
:client_repos_field
)
{
:repos
}
let
(
:client_repos_field
)
{
:repos
}
end
end
context
'with new_import_ui feature flag enabled'
do
before
do
stub_feature_flags
(
new_import_ui:
true
)
allow
(
controller
).
to
receive
(
:provider_url
).
and_return
(
'http://demobitbucket.org'
)
end
it
'returns invalid repos'
do
allow_any_instance_of
(
Bitbucket
::
Client
).
to
receive
(
:repos
).
and_return
([
@repo
,
@invalid_repo
])
get
:status
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'incompatible_repos'
].
length
).
to
eq
(
1
)
expect
(
json_response
.
dig
(
"incompatible_repos"
,
0
,
"id"
)).
to
eq
(
@invalid_repo
.
full_name
)
expect
(
json_response
[
'provider_repos'
].
length
).
to
eq
(
1
)
expect
(
json_response
.
dig
(
"provider_repos"
,
0
,
"id"
)).
to
eq
(
@repo
.
full_name
)
end
end
it
"assigns variables"
do
it
"assigns variables"
do
@project
=
create
(
:project
,
import_type:
'bitbucket'
,
creator_id:
user
.
id
)
@project
=
create
(
:project
,
import_type:
'bitbucket'
,
creator_id:
user
.
id
)
allow_any_instance_of
(
Bitbucket
::
Client
).
to
receive
(
:repos
).
and_return
([
@repo
])
allow_any_instance_of
(
Bitbucket
::
Client
).
to
receive
(
:repos
).
and_return
([
@repo
])
...
...
spec/controllers/import/bitbucket_server_controller_spec.rb
View file @
57b914cc
...
@@ -142,12 +142,30 @@ RSpec.describe Import::BitbucketServerController do
...
@@ -142,12 +142,30 @@ RSpec.describe Import::BitbucketServerController do
allow
(
controller
).
to
receive
(
:client
).
and_return
(
client
)
allow
(
controller
).
to
receive
(
:client
).
and_return
(
client
)
@repo
=
double
(
slug:
'vim'
,
project_key:
'asd'
,
full_name:
'asd/vim'
,
"valid?"
=>
true
,
project_name:
'asd'
,
browse_url:
'http://test'
,
name:
'vim'
)
@repo
=
double
(
slug:
'vim'
,
project_key:
'asd'
,
full_name:
'asd/vim'
,
"valid?"
=>
true
,
project_name:
'asd'
,
browse_url:
'http://test'
,
name:
'vim'
)
@invalid_repo
=
double
(
slug:
'invalid'
,
project_key:
'foobar'
,
full_name:
'asd/foobar'
,
"valid?"
=>
false
,
browse_url:
'http://bad-repo'
)
@invalid_repo
=
double
(
slug:
'invalid'
,
project_key:
'foobar'
,
full_name:
'asd/foobar'
,
"valid?"
=>
false
,
browse_url:
'http://bad-repo'
,
name:
'invalid'
)
@created_repo
=
double
(
slug:
'created'
,
project_key:
'existing'
,
full_name:
'group/created'
,
"valid?"
=>
true
,
browse_url:
'http://existing'
)
@created_repo
=
double
(
slug:
'created'
,
project_key:
'existing'
,
full_name:
'group/created'
,
"valid?"
=>
true
,
browse_url:
'http://existing'
)
assign_session_tokens
assign_session_tokens
stub_feature_flags
(
new_import_ui:
false
)
stub_feature_flags
(
new_import_ui:
false
)
end
end
context
'with new_import_ui feature flag enabled'
do
before
do
stub_feature_flags
(
new_import_ui:
true
)
end
it
'returns invalid repos'
do
allow
(
client
).
to
receive
(
:repos
).
with
(
filter:
nil
,
limit:
25
,
page_offset:
0
).
and_return
([
@repo
,
@invalid_repo
])
get
:status
,
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'incompatible_repos'
].
length
).
to
eq
(
1
)
expect
(
json_response
.
dig
(
"incompatible_repos"
,
0
,
"id"
)).
to
eq
(
@invalid_repo
.
full_name
)
expect
(
json_response
[
'provider_repos'
].
length
).
to
eq
(
1
)
expect
(
json_response
.
dig
(
"provider_repos"
,
0
,
"id"
)).
to
eq
(
@repo
.
full_name
)
end
end
it_behaves_like
'import controller with new_import_ui feature flag'
do
it_behaves_like
'import controller with new_import_ui feature flag'
do
let
(
:repo
)
{
@repo
}
let
(
:repo
)
{
@repo
}
let
(
:repo_id
)
{
@repo
.
full_name
}
let
(
:repo_id
)
{
@repo
.
full_name
}
...
...
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