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
dcd2eeb1
Commit
dcd2eeb1
authored
Mar 23, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename container image to repository in specs
parent
3e01fed5
Changes
15
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
33 additions
and
33 deletions
+33
-33
app/models/namespace.rb
app/models/namespace.rb
+1
-1
app/models/project.rb
app/models/project.rb
+2
-2
app/services/projects/transfer_service.rb
app/services/projects/transfer_service.rb
+1
-1
spec/features/container_registry_spec.rb
spec/features/container_registry_spec.rb
+4
-4
spec/features/security/project/internal_access_spec.rb
spec/features/security/project/internal_access_spec.rb
+2
-2
spec/features/security/project/private_access_spec.rb
spec/features/security/project/private_access_spec.rb
+2
-2
spec/features/security/project/public_access_spec.rb
spec/features/security/project/public_access_spec.rb
+2
-2
spec/lib/container_registry/blob_spec.rb
spec/lib/container_registry/blob_spec.rb
+1
-1
spec/lib/container_registry/tag_spec.rb
spec/lib/container_registry/tag_spec.rb
+1
-1
spec/lib/gitlab/import_export/all_models.yml
spec/lib/gitlab/import_export/all_models.yml
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+2
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+2
-2
spec/services/container_images/destroy_service_spec.rb
spec/services/container_images/destroy_service_spec.rb
+8
-8
spec/services/projects/destroy_service_spec.rb
spec/services/projects/destroy_service_spec.rb
+2
-2
spec/services/projects/transfer_service_spec.rb
spec/services/projects/transfer_service_spec.rb
+2
-2
No files found.
app/models/namespace.rb
View file @
dcd2eeb1
...
...
@@ -150,7 +150,7 @@ class Namespace < ActiveRecord::Base
end
def
any_project_has_container_registry_images?
projects
.
joins
(
:container_
imag
es
).
any?
projects
.
joins
(
:container_
repositori
es
).
any?
end
def
send_update_instructions
...
...
app/models/project.rb
View file @
dcd2eeb1
...
...
@@ -157,7 +157,7 @@ class Project < ActiveRecord::Base
has_one
:import_data
,
dependent: :destroy
,
class_name:
"ProjectImportData"
has_one
:project_feature
,
dependent: :destroy
has_one
:statistics
,
class_name:
'ProjectStatistics'
,
dependent: :delete
has_many
:container_
imag
es
,
dependent: :destroy
has_many
:container_
repositori
es
,
dependent: :destroy
has_many
:commit_statuses
,
dependent: :destroy
has_many
:pipelines
,
dependent: :destroy
,
class_name:
'Ci::Pipeline'
...
...
@@ -908,7 +908,7 @@ class Project < ActiveRecord::Base
expire_caches_before_rename
(
old_path_with_namespace
)
if
container_
imag
es
.
present?
if
container_
repositori
es
.
present?
Rails
.
logger
.
error
"Project
#{
old_path_with_namespace
}
cannot be renamed because container registry images are present"
# we currently doesn't support renaming repository if it contains images in container registry
...
...
app/services/projects/transfer_service.rb
View file @
dcd2eeb1
...
...
@@ -36,7 +36,7 @@ module Projects
raise
TransferError
.
new
(
"Project with same path in target namespace already exists"
)
end
unless
project
.
container_
imag
es
.
empty?
unless
project
.
container_
repositori
es
.
empty?
# we currently doesn't support renaming repository if it contains images in container registry
raise
TransferError
.
new
(
'Project cannot be transferred, because images are present in its container registry'
)
end
...
...
spec/features/container_registry_spec.rb
View file @
dcd2eeb1
...
...
@@ -5,15 +5,15 @@ describe "Container Registry" do
let
(
:registry
)
{
project
.
container_registry
}
let
(
:tag_name
)
{
'latest'
}
let
(
:tags
)
{
[
tag_name
]
}
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:image_name
)
{
container_
image
.
name
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
let
(
:image_name
)
{
container_
repository
.
name
}
before
do
login_as
(
:user
)
project
.
team
<<
[
@user
,
:developer
]
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
*
tags
)
project
.
container_
images
<<
container_image
unless
container_image
.
nil?
project
.
container_
repositories
<<
container_repository
unless
container_repository
.
nil?
allow
(
Auth
::
ContainerRegistryAuthenticationService
).
to
receive
(
:full_access_token
).
and_return
(
'token'
)
end
...
...
@@ -23,7 +23,7 @@ describe "Container Registry" do
end
context
'when no images'
do
let
(
:container_
image
)
{
}
let
(
:container_
repository
)
{
}
it
{
expect
(
page
).
to
have_content
(
'No container images in Container Registry for this project'
)
}
end
...
...
spec/features/security/project/internal_access_spec.rb
View file @
dcd2eeb1
...
...
@@ -443,12 +443,12 @@ describe "Internal Project Access", feature: true do
end
describe
"GET /:project_path/container_registry"
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_
images
<<
container_image
project
.
container_
repositories
<<
container_repository
end
subject
{
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
}
...
...
spec/features/security/project/private_access_spec.rb
View file @
dcd2eeb1
...
...
@@ -432,12 +432,12 @@ describe "Private Project Access", feature: true do
end
describe
"GET /:project_path/container_registry"
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_
images
<<
container_image
project
.
container_
repositories
<<
container_repository
end
subject
{
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
}
...
...
spec/features/security/project/public_access_spec.rb
View file @
dcd2eeb1
...
...
@@ -443,12 +443,12 @@ describe "Public Project Access", feature: true do
end
describe
"GET /:project_path/container_registry"
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_tags
(
'latest'
)
stub_container_registry_config
(
enabled:
true
)
project
.
container_
images
<<
container_image
project
.
container_
repositories
<<
container_repository
end
subject
{
namespace_project_container_registry_index_path
(
project
.
namespace
,
project
)
}
...
...
spec/lib/container_registry/blob_spec.rb
View file @
dcd2eeb1
...
...
@@ -15,7 +15,7 @@ describe ContainerRegistry::Blob do
let
(
:project
)
{
create
(
:project
,
path:
'test'
,
group:
group
)
}
let
(
:example_host
)
{
'example.com'
}
let
(
:registry_url
)
{
'http://'
+
example_host
}
let
(
:repository
)
{
create
(
:container_
image
,
name:
''
,
project:
project
)
}
let
(
:repository
)
{
create
(
:container_
repository
,
name:
''
,
project:
project
)
}
let
(
:blob
)
{
repository
.
blob
(
config
)
}
before
do
...
...
spec/lib/container_registry/tag_spec.rb
View file @
dcd2eeb1
...
...
@@ -5,7 +5,7 @@ describe ContainerRegistry::Tag do
let
(
:project
)
{
create
(
:project
,
path:
'test'
,
group:
group
)
}
let
(
:example_host
)
{
'example.com'
}
let
(
:registry_url
)
{
'http://'
+
example_host
}
let
(
:repository
)
{
create
(
:container_
image
,
name:
''
,
project:
project
)
}
let
(
:repository
)
{
create
(
:container_
repository
,
name:
''
,
project:
project
)
}
let
(
:tag
)
{
repository
.
tag
(
'tag'
)
}
let
(
:headers
)
{
{
'Accept'
=>
'application/vnd.docker.distribution.manifest.v2+json'
}
}
...
...
spec/lib/gitlab/import_export/all_models.yml
View file @
dcd2eeb1
...
...
@@ -115,7 +115,7 @@ merge_access_levels:
-
protected_branch
push_access_levels
:
-
protected_branch
container_
imag
es
:
container_
repositori
es
:
-
name
project
:
-
taggings
...
...
spec/models/namespace_spec.rb
View file @
dcd2eeb1
...
...
@@ -149,13 +149,13 @@ describe Namespace, models: true do
end
context
"when any project has container images"
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
create
(
:empty_project
,
namespace:
@namespace
,
container_
images:
[
container_image
])
create
(
:empty_project
,
namespace:
@namespace
,
container_
repositories:
[
container_repository
])
allow
(
@namespace
).
to
receive
(
:path_was
).
and_return
(
@namespace
.
path
)
allow
(
@namespace
).
to
receive
(
:path
).
and_return
(
'new_path'
)
...
...
spec/models/project_spec.rb
View file @
dcd2eeb1
...
...
@@ -1186,12 +1186,12 @@ describe Project, models: true do
end
context
'container registry with images'
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
project
.
container_
images
<<
container_image
project
.
container_
repositories
<<
container_repository
end
subject
{
project
.
rename_repo
}
...
...
spec/services/container_images/destroy_service_spec.rb
View file @
dcd2eeb1
...
...
@@ -3,13 +3,13 @@ require 'spec_helper'
describe
ContainerImages
::
DestroyService
,
services:
true
do
describe
'#execute'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:container_
image
)
{
create
(
:container_image
,
name:
''
)
}
let
(
:project
)
{
create
(
:project
,
path:
'test'
,
namespace:
user
.
namespace
,
container_
images:
[
container_image
])
}
let
(
:container_
repository
)
{
create
(
:container_repository
,
name:
''
)
}
let
(
:project
)
{
create
(
:project
,
path:
'test'
,
namespace:
user
.
namespace
,
container_
repositorys:
[
container_repository
])
}
let
(
:example_host
)
{
'example.com'
}
let
(
:registry_url
)
{
'http://'
+
example_host
}
it
{
expect
(
container_
image
).
to
be_valid
}
it
{
expect
(
project
.
container_
image
s
).
not_to
be_empty
}
it
{
expect
(
container_
repository
).
to
be_valid
}
it
{
expect
(
project
.
container_
repository
s
).
not_to
be_empty
}
context
'when container image has tags'
do
before
do
...
...
@@ -19,15 +19,15 @@ describe ContainerImages::DestroyService, services: true do
it
'removes all tags before destroy'
do
service
=
described_class
.
new
(
project
,
user
)
expect
(
container_
image
).
to
receive
(
:delete_tags
).
and_return
(
true
)
expect
{
service
.
execute
(
container_
image
)
}.
to
change
(
project
.
container_image
s
,
:count
).
by
(
-
1
)
expect
(
container_
repository
).
to
receive
(
:delete_tags
).
and_return
(
true
)
expect
{
service
.
execute
(
container_
repository
)
}.
to
change
(
project
.
container_repository
s
,
:count
).
by
(
-
1
)
end
it
'fails when tags are not removed'
do
service
=
described_class
.
new
(
project
,
user
)
expect
(
container_
image
).
to
receive
(
:delete_tags
).
and_return
(
false
)
expect
{
service
.
execute
(
container_
image
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotDestroyed
)
expect
(
container_
repository
).
to
receive
(
:delete_tags
).
and_return
(
false
)
expect
{
service
.
execute
(
container_
repository
)
}.
to
raise_error
(
ActiveRecord
::
RecordNotDestroyed
)
end
end
end
...
...
spec/services/projects/destroy_service_spec.rb
View file @
dcd2eeb1
...
...
@@ -90,12 +90,12 @@ describe Projects::DestroyService, services: true do
end
context
'container registry'
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
project
.
container_
images
<<
container_image
project
.
container_
repositorys
<<
container_repository
end
context
'images deletion succeeds'
do
...
...
spec/services/projects/transfer_service_spec.rb
View file @
dcd2eeb1
...
...
@@ -29,12 +29,12 @@ describe Projects::TransferService, services: true do
end
context
'disallow transfering of project with tags'
do
let
(
:container_
image
)
{
create
(
:container_image
)
}
let
(
:container_
repository
)
{
create
(
:container_repository
)
}
before
do
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
'tag'
)
project
.
container_
images
<<
container_image
project
.
container_
repositorys
<<
container_repository
end
subject
{
transfer_project
(
project
,
user
,
group
)
}
...
...
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