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
91c4002a
Commit
91c4002a
authored
May 16, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve test coverage
parent
72a71e9d
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
76 additions
and
7 deletions
+76
-7
lib/container_registry/repository.rb
lib/container_registry/repository.rb
+1
-1
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+14
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+15
-4
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+29
-0
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+11
-0
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+5
-1
No files found.
lib/container_registry/repository.rb
View file @
91c4002a
...
...
@@ -39,7 +39,7 @@ module ContainerRegistry
def
delete_tags
return
unless
tags
tags
.
each
(
:delete
)
tags
.
all?
(
&
:delete
)
end
def
mount_blob
(
blob
)
...
...
spec/features/container_registry_spec.rb
View file @
91c4002a
...
...
@@ -14,7 +14,7 @@ describe "Container Registry" do
before
do
login_as
(
:user
)
project
.
team
<<
[
@user
,
:developer
]
stub_container_registry
(
*
tags
)
stub_container_registry
_tags
(
*
tags
)
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
registry_settings
)
allow
(
Auth
::
ContainerRegistryAuthenticationService
).
to
receive
(
:full_access_token
).
and_return
(
'token'
)
end
...
...
spec/models/namespace_spec.rb
View file @
91c4002a
...
...
@@ -70,6 +70,20 @@ describe Namespace, models: true do
allow
(
@namespace
).
to
receive
(
:path
).
and_return
(
new_path
)
expect
(
@namespace
.
move_dir
).
to
be_truthy
end
context
"when any project has container tags"
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
create
(
:empty_project
,
namespace:
@namespace
)
allow
(
@namespace
).
to
receive
(
:path_was
).
and_return
(
@namespace
.
path
)
allow
(
@namespace
).
to
receive
(
:path
).
and_return
(
'new_path'
)
end
it
{
expect
{
@namespace
.
move_dir
}.
to
raise_error
(
'Namespace cannot be moved, because at least one project has tags in container registry'
)
}
end
end
describe
:rm_dir
do
...
...
spec/models/project_spec.rb
View file @
91c4002a
...
...
@@ -634,11 +634,11 @@ describe Project, models: true do
# Project#gitlab_shell returns a new instance of Gitlab::Shell on every
# call. This makes testing a bit easier.
allow
(
project
).
to
receive
(
:gitlab_shell
).
and_return
(
gitlab_shell
)
end
it
'renames a repository'
do
allow
(
project
).
to
receive
(
:previous_changes
).
and_return
(
'path'
=>
[
'foo'
])
end
it
'renames a repository'
do
ns
=
project
.
namespace_dir
expect
(
gitlab_shell
).
to
receive
(
:mv_repository
).
...
...
@@ -663,6 +663,17 @@ describe Project, models: true do
project
.
rename_repo
end
context
'container registry with tags'
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
end
subject
{
project
.
rename_repo
}
it
{
expect
{
subject
}.
to
raise_error
(
Exception
)
}
end
end
describe
'#expire_caches_before_rename'
do
...
...
@@ -825,13 +836,13 @@ describe Project, models: true do
end
context
'with tags'
do
before
{
stub_container_registry
(
'test'
,
'test2'
)
}
before
{
stub_container_registry
_tags
(
'test'
,
'test2'
)
}
it
{
is_expected
.
to
be_truthy
}
end
context
'when no tags'
do
before
{
stub_container_registry
}
before
{
stub_container_registry
_tags
}
it
{
is_expected
.
to
be_falsey
}
end
...
...
spec/services/projects/destroy_service_spec.rb
View file @
91c4002a
...
...
@@ -28,6 +28,35 @@ describe Projects::DestroyService, services: true do
it
{
expect
(
Dir
.
exist?
(
remove_path
)).
to
be_truthy
}
end
context
'container registry'
do
let
(
:registry_settings
)
do
{
enabled:
true
}
end
before
do
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
registry_settings
)
stub_container_registry_tags
(
'tag'
)
end
context
'tags deletion succeeds'
do
it
do
expect_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
and_return
(
true
)
destroy_project
(
project
,
user
,
{})
end
end
context
'tags deletion fails'
do
before
{
expect_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
).
and_return
(
false
)
}
subject
{
destroy_project
(
project
,
user
,
{})
}
it
{
expect
{
subject
}.
to
raise_error
(
Projects
::
DestroyService
::
DestroyError
)
}
end
end
def
destroy_project
(
project
,
user
,
params
)
Projects
::
DestroyService
.
new
(
project
,
user
,
params
).
execute
end
...
...
spec/services/projects/transfer_service_spec.rb
View file @
91c4002a
...
...
@@ -26,6 +26,17 @@ describe Projects::TransferService, services: true do
it
{
expect
(
project
.
namespace
).
to
eq
(
user
.
namespace
)
}
end
context
'disallow transfering of project with tags'
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
end
subject
{
transfer_project
(
project
,
user
,
group
)
}
it
{
is_expected
.
to
be_falsey
}
end
context
'namespace -> not allowed namespace'
do
before
do
@result
=
transfer_project
(
project
,
user
,
group
)
...
...
spec/support/stub_gitlab_calls.rb
View file @
91c4002a
...
...
@@ -25,7 +25,11 @@ module StubGitlabCalls
allow_any_instance_of
(
Project
).
to
receive
(
:builds_enabled?
).
and_return
(
false
)
end
def
stub_container_registry
(
*
tags
)
def
stub_container_registry_config
(
registry_settings
)
allow
(
Gitlab
.
config
.
registry
).
to
receive_messages
(
registry_settings
)
end
def
stub_container_registry_tags
(
*
tags
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_tags
).
and_return
(
{
"tags"
=>
tags
}
)
...
...
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