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
Jérome Perrin
gitlab-ce
Commits
662d2e68
Commit
662d2e68
authored
Apr 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor feature specs for container registry
parent
fc550b39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
41 deletions
+42
-41
app/views/projects/registry/repositories/_tag.html.haml
app/views/projects/registry/repositories/_tag.html.haml
+1
-1
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+33
-32
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+8
-8
No files found.
app/views/projects/registry/repositories/_tag.html.haml
View file @
662d2e68
...
...
@@ -29,6 +29,6 @@
=
link_to
namespace_project_registry_repository_tag_path
(
@project
.
namespace
,
@project
,
tag
.
repository
,
tag
.
name
),
method: :delete
,
class:
'btn btn-remove has-tooltip'
,
title:
'Remove
image
tag'
,
title:
'Remove tag'
,
data:
{
confirm:
notice
}
do
=
icon
(
'trash cred'
)
spec/features/container_registry_spec.rb
View file @
662d2e68
require
'spec_helper'
describe
"Container Registry"
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:registry
)
{
project
.
container_registry
}
let
(
:tag_name
)
{
'latest'
}
let
(
:tags
)
{
[
tag_name
]
}
let
(
:container_repository
)
{
create
(
:container_repository
)
}
let
(
:image_name
)
{
container_repository
.
name
}
let
(
:container_repository
)
do
create
(
:container_repository
,
name:
'my/image'
)
end
before
do
login_as
(
:
user
)
project
.
team
<<
[
@user
,
:developer
]
login_as
(
user
)
project
.
add_developer
(
user
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
*
tags
)
project
.
container_repositories
<<
container_repository
unless
container_repository
.
nil?
stub_container_registry_tags
(
%w[latest]
)
end
describe
'GET /:project/container_registry'
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
context
'when no images'
do
let
(
:container_repository
)
{
}
it
{
expect
(
page
).
to
have_content
(
'No container images in Container Registry for this project'
)
}
end
context
'when there are no image repositories'
do
scenario
'user visits container registry main page'
do
visit_container_registry
context
'when there are images'
do
it
{
expect
(
page
).
to
have_content
(
image_name
)
}
expect
(
page
).
to
have_content
'No container images'
end
end
describe
'DELETE /:project/container_registry/:image_id
'
do
context
'when there are image repositories
'
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
project
.
container_repositories
<<
container_repository
end
scenario
'user wants to see multi-level container repository'
do
visit_container_registry
expect
(
page
).
to
have_content
(
'my/image'
)
end
it
do
scenario
'user removes entire container repository'
do
visit_container_registry
expect_any_instance_of
(
ContainerRepository
)
.
to
receive
(
:delete_tags!
).
and_return
(
true
)
click_on
'Remove
image
'
click_on
'Remove
repository
'
end
end
describe
'DELETE /:project/container_registry/tag'
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
scenario
'user removes a specific tag from container repository'
do
visit_container_registry
it
do
expect_any_instance_of
(
::
ContainerRegistry
::
Tag
)
.
to
receive
(
:delete
).
and_return
(
true
)
expect_any_instance_of
(
ContainerRegistry
::
Tag
)
.
to
receive
(
:delete
).
and_return
(
true
)
click_on
'Remove tag'
end
end
def
visit_container_registry
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
end
spec/support/stub_gitlab_calls.rb
View file @
662d2e68
...
...
@@ -32,15 +32,15 @@ module StubGitlabCalls
end
def
stub_container_registry_tags
(
*
tags
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_tags
).
and_return
(
{
"tags"
=>
tags
}
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_manifest
).
and_return
(
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/tag_manifest.json'
))
)
allow_any_instance_of
(
ContainerRegistry
::
Client
)
.
to
receive
(
:repository_tags
).
and_return
({
'tags'
=>
tags
})
allow_any_instance_of
(
ContainerRegistry
::
Client
)
.
to
receive
(
:repository_manifest
).
and_return
(
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/tag_manifest.json'
)))
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:blob
).
and_return
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/config_blob.json'
)
)
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/config_blob.json'
))
end
private
...
...
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