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
Léo-Paul Géneau
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
Show 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 @@
...
@@ -29,6 +29,6 @@
=
link_to
namespace_project_registry_repository_tag_path
(
@project
.
namespace
,
@project
,
tag
.
repository
,
tag
.
name
),
=
link_to
namespace_project_registry_repository_tag_path
(
@project
.
namespace
,
@project
,
tag
.
repository
,
tag
.
name
),
method: :delete
,
method: :delete
,
class:
'btn btn-remove has-tooltip'
,
class:
'btn btn-remove has-tooltip'
,
title:
'Remove
image
tag'
,
title:
'Remove tag'
,
data:
{
confirm:
notice
}
do
data:
{
confirm:
notice
}
do
=
icon
(
'trash cred'
)
=
icon
(
'trash cred'
)
spec/features/container_registry_spec.rb
View file @
662d2e68
require
'spec_helper'
require
'spec_helper'
describe
"Container Registry"
do
describe
"Container Registry"
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
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
}
before
do
let
(
:container_repository
)
do
login_as
(
:user
)
create
(
:container_repository
,
name:
'my/image'
)
project
.
team
<<
[
@user
,
:developer
]
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
*
tags
)
project
.
container_repositories
<<
container_repository
unless
container_repository
.
nil?
end
end
describe
'GET /:project/container_registry'
do
before
do
before
do
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
login_as
(
user
)
project
.
add_developer
(
user
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
%w[latest]
)
end
end
context
'when no images'
do
context
'when there are no image repositories'
do
let
(
:container_repository
)
{
}
scenario
'user visits container registry main page'
do
visit_container_registry
it
{
expect
(
page
).
to
have_content
(
'No container images in Container Registry for this project'
)
}
expect
(
page
).
to
have_content
'No container images'
end
context
'when there are images'
do
it
{
expect
(
page
).
to
have_content
(
image_name
)
}
end
end
end
end
describe
'DELETE /:project/container_registry/:image_id
'
do
context
'when there are image repositories
'
do
before
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
end
it
do
scenario
'user removes entire container repository'
do
visit_container_registry
expect_any_instance_of
(
ContainerRepository
)
expect_any_instance_of
(
ContainerRepository
)
.
to
receive
(
:delete_tags!
).
and_return
(
true
)
.
to
receive
(
:delete_tags!
).
and_return
(
true
)
click_on
'Remove image'
click_on
'Remove repository'
end
end
end
describe
'DELETE /:project/container_registry/tag'
do
scenario
'user removes a specific tag from container repository'
do
before
do
visit_container_registry
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
it
do
expect_any_instance_of
(
ContainerRegistry
::
Tag
)
expect_any_instance_of
(
::
ContainerRegistry
::
Tag
)
.
to
receive
(
:delete
).
and_return
(
true
)
.
to
receive
(
:delete
).
and_return
(
true
)
click_on
'Remove tag'
click_on
'Remove tag'
end
end
end
end
def
visit_container_registry
visit
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
end
end
end
spec/support/stub_gitlab_calls.rb
View file @
662d2e68
...
@@ -32,15 +32,15 @@ module StubGitlabCalls
...
@@ -32,15 +32,15 @@ module StubGitlabCalls
end
end
def
stub_container_registry_tags
(
*
tags
)
def
stub_container_registry_tags
(
*
tags
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_tags
).
and_return
(
allow_any_instance_of
(
ContainerRegistry
::
Client
)
{
"tags"
=>
tags
}
.
to
receive
(
:repository_tags
).
and_return
({
'tags'
=>
tags
})
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:repository_manifest
).
and_return
(
allow_any_instance_of
(
ContainerRegistry
::
Client
)
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/tag_manifest.json'
))
.
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
(
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
end
private
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