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
Boxiang Sun
gitlab-ce
Commits
baa00d54
Commit
baa00d54
authored
Apr 03, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor container registry repository tag stubs
parent
0af4cbc5
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
17 deletions
+35
-17
spec/controllers/projects/registry/repositories_controller_spec.rb
...rollers/projects/registry/repositories_controller_spec.rb
+4
-3
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+2
-1
spec/features/security/project/internal_access_spec.rb
spec/features/security/project/internal_access_spec.rb
+1
-1
spec/features/security/project/private_access_spec.rb
spec/features/security/project/private_access_spec.rb
+1
-1
spec/features/security/project/public_access_spec.rb
spec/features/security/project/public_access_spec.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+1
-1
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+1
-1
spec/support/stub_gitlab_calls.rb
spec/support/stub_gitlab_calls.rb
+22
-6
No files found.
spec/controllers/projects/registry/repositories_controller_spec.rb
View file @
baa00d54
...
@@ -24,10 +24,11 @@ describe Projects::Registry::RepositoriesController do
...
@@ -24,10 +24,11 @@ describe Projects::Registry::RepositoriesController do
end
end
end
end
context
'when root container repository
does not exist
'
do
context
'when root container repository
is not created
'
do
context
'when there are tags for this repository'
do
context
'when there are tags for this repository'
do
before
do
before
do
stub_container_registry_tags
(
%w[rc1 latest]
)
stub_container_registry_tags
(
repository:
project
.
full_path
,
tags:
%w[rc1 latest]
)
end
end
it
'successfully renders container repositories'
do
it
'successfully renders container repositories'
do
...
@@ -44,7 +45,7 @@ describe Projects::Registry::RepositoriesController do
...
@@ -44,7 +45,7 @@ describe Projects::Registry::RepositoriesController do
context
'when there are no tags for this repository'
do
context
'when there are no tags for this repository'
do
before
do
before
do
stub_container_registry_tags
(
*
[])
stub_container_registry_tags
(
repository: :any
,
tags:
[])
end
end
it
'successfully renders container repositories'
do
it
'successfully renders container repositories'
do
...
...
spec/features/container_registry_spec.rb
View file @
baa00d54
...
@@ -12,7 +12,7 @@ describe "Container Registry" do
...
@@ -12,7 +12,7 @@ describe "Container Registry" do
login_as
(
user
)
login_as
(
user
)
project
.
add_developer
(
user
)
project
.
add_developer
(
user
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
%w[latest
]
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
])
end
end
context
'when there are no image repositories'
do
context
'when there are no image repositories'
do
...
@@ -25,6 +25,7 @@ describe "Container Registry" do
...
@@ -25,6 +25,7 @@ describe "Container Registry" do
context
'when there are image repositories'
do
context
'when there are image repositories'
do
before
do
before
do
stub_container_registry_tags
(
repository:
%r{my/image}
,
tags:
%w[latest]
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/features/security/project/internal_access_spec.rb
View file @
baa00d54
...
@@ -446,7 +446,7 @@ describe "Internal Project Access", feature: true do
...
@@ -446,7 +446,7 @@ describe "Internal Project Access", feature: true do
let
(
:container_repository
)
{
create
(
:container_repository
)
}
let
(
:container_repository
)
{
create
(
:container_repository
)
}
before
do
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'latest'
]
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/features/security/project/private_access_spec.rb
View file @
baa00d54
...
@@ -435,7 +435,7 @@ describe "Private Project Access", feature: true do
...
@@ -435,7 +435,7 @@ describe "Private Project Access", feature: true do
let
(
:container_repository
)
{
create
(
:container_repository
)
}
let
(
:container_repository
)
{
create
(
:container_repository
)
}
before
do
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'latest'
]
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/features/security/project/public_access_spec.rb
View file @
baa00d54
...
@@ -446,7 +446,7 @@ describe "Public Project Access", feature: true do
...
@@ -446,7 +446,7 @@ describe "Public Project Access", feature: true do
let
(
:container_repository
)
{
create
(
:container_repository
)
}
let
(
:container_repository
)
{
create
(
:container_repository
)
}
before
do
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_tags
(
repository: :any
,
tags
:[
'latest'
]
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/models/namespace_spec.rb
View file @
baa00d54
...
@@ -153,7 +153,7 @@ describe Namespace, models: true do
...
@@ -153,7 +153,7 @@ describe Namespace, models: true do
before
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
]
)
create
(
:empty_project
,
namespace:
@namespace
,
container_repositories:
[
container_repository
])
create
(
:empty_project
,
namespace:
@namespace
,
container_repositories:
[
container_repository
])
...
...
spec/models/project_spec.rb
View file @
baa00d54
...
@@ -1190,7 +1190,7 @@ describe Project, models: true do
...
@@ -1190,7 +1190,7 @@ describe Project, models: true do
before
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
]
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/services/projects/destroy_service_spec.rb
View file @
baa00d54
...
@@ -94,7 +94,7 @@ describe Projects::DestroyService, services: true do
...
@@ -94,7 +94,7 @@ describe Projects::DestroyService, services: true do
before
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
]
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/services/projects/transfer_service_spec.rb
View file @
baa00d54
...
@@ -33,7 +33,7 @@ describe Projects::TransferService, services: true do
...
@@ -33,7 +33,7 @@ describe Projects::TransferService, services: true do
before
do
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
]
)
project
.
container_repositories
<<
container_repository
project
.
container_repositories
<<
container_repository
end
end
...
...
spec/support/stub_gitlab_calls.rb
View file @
baa00d54
...
@@ -31,20 +31,36 @@ module StubGitlabCalls
...
@@ -31,20 +31,36 @@ module StubGitlabCalls
.
to
receive
(
:full_access_token
).
and_return
(
'token'
)
.
to
receive
(
:full_access_token
).
and_return
(
'token'
)
end
end
def
stub_container_registry_tags
(
*
tags
)
def
stub_container_registry_tags
(
repository: :any
,
tags
:)
repository
=
any_args
if
repository
==
:any
allow_any_instance_of
(
ContainerRegistry
::
Client
)
allow_any_instance_of
(
ContainerRegistry
::
Client
)
.
to
receive
(
:repository_tags
).
and_return
({
'tags'
=>
tags
})
.
to
receive
(
:repository_tags
).
with
(
repository
)
.
and_return
({
'tags'
=>
tags
})
allow_any_instance_of
(
ContainerRegistry
::
Client
)
allow_any_instance_of
(
ContainerRegistry
::
Client
)
.
to
receive
(
:repository_manifest
).
and_return
(
.
to
receive
(
:repository_manifest
).
with
(
repository
)
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/tag_manifest.json'
))
)
.
and_return
(
stub_container_registry_tag_manifest
)
allow_any_instance_of
(
ContainerRegistry
::
Client
).
to
receive
(
:blob
).
and_return
(
allow_any_instance_of
(
ContainerRegistry
::
Client
)
File
.
read
(
Rails
.
root
+
'spec/fixtures/container_registry/config_blob.json'
))
.
to
receive
(
:blob
).
with
(
repository
)
.
and_return
(
stub_container_registry_blob
)
end
end
private
private
def
stub_container_registry_tag_manifest
fixture_path
=
'spec/fixtures/container_registry/tag_manifest.json'
JSON
.
parse
(
File
.
read
(
Rails
.
root
+
fixture_path
))
end
def
stub_container_registry_blob
fixture_path
=
'spec/fixtures/container_registry/config_blob.json'
File
.
read
(
Rails
.
root
+
fixture_path
)
end
def
gitlab_url
def
gitlab_url
Gitlab
.
config
.
gitlab
.
url
Gitlab
.
config
.
gitlab
.
url
end
end
...
...
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