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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
97d0bf88
Commit
97d0bf88
authored
Sep 05, 2019
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tracking to registry repos
Add track_event() hooks to track package events
parent
e3421799
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
0 deletions
+35
-0
app/controllers/projects/registry/repositories_controller.rb
app/controllers/projects/registry/repositories_controller.rb
+2
-0
app/controllers/projects/registry/tags_controller.rb
app/controllers/projects/registry/tags_controller.rb
+3
-0
spec/controllers/projects/registry/repositories_controller_spec.rb
...rollers/projects/registry/repositories_controller_spec.rb
+12
-0
spec/controllers/projects/registry/tags_controller_spec.rb
spec/controllers/projects/registry/tags_controller_spec.rb
+18
-0
No files found.
app/controllers/projects/registry/repositories_controller.rb
View file @
97d0bf88
...
...
@@ -8,6 +8,7 @@ module Projects
def
index
@images
=
project
.
container_repositories
track_event
(
:list_repositories
)
respond_to
do
|
format
|
format
.
html
...
...
@@ -21,6 +22,7 @@ module Projects
def
destroy
DeleteContainerRepositoryWorker
.
perform_async
(
current_user
.
id
,
image
.
id
)
track_event
(
:delete_repository
)
respond_to
do
|
format
|
format
.
json
{
head
:no_content
}
...
...
app/controllers/projects/registry/tags_controller.rb
View file @
97d0bf88
...
...
@@ -8,6 +8,7 @@ module Projects
LIMIT
=
15
def
index
track_event
(
:list_tags
)
respond_to
do
|
format
|
format
.
json
do
render
json:
ContainerTagsSerializer
...
...
@@ -22,6 +23,7 @@ module Projects
result
=
Projects
::
ContainerRepository
::
DeleteTagsService
.
new
(
image
.
project
,
current_user
,
tags:
[
params
[
:id
]])
.
execute
(
image
)
track_event
(
:delete_tag
)
respond_to
do
|
format
|
format
.
json
{
head
(
result
[
:status
]
==
:success
?
:ok
:
bad_request
)
}
...
...
@@ -43,6 +45,7 @@ module Projects
result
=
Projects
::
ContainerRepository
::
DeleteTagsService
.
new
(
image
.
project
,
current_user
,
tags:
tag_names
)
.
execute
(
image
)
track_event
(
:delete_tag_bulk
)
respond_to
do
|
format
|
format
.
json
{
head
(
result
[
:status
]
==
:success
?
:no_content
:
:bad_request
)
}
...
...
spec/controllers/projects/registry/repositories_controller_spec.rb
View file @
97d0bf88
...
...
@@ -40,6 +40,11 @@ describe Projects::Registry::RepositoriesController do
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
end
it
'tracks the event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
anything
,
'list_repositories'
,
{})
go_to_index
end
it
'creates a root container repository'
do
expect
{
go_to_index
}.
to
change
{
ContainerRepository
.
all
.
count
}.
by
(
1
)
expect
(
ContainerRepository
.
first
).
to
be_root_repository
...
...
@@ -94,6 +99,13 @@ describe Projects::Registry::RepositoriesController do
delete_repository
(
repository
)
expect
(
response
).
to
have_gitlab_http_status
(
:no_content
)
end
it
'tracks the event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
anything
,
'delete_repository'
,
{})
allow
(
DeleteContainerRepositoryWorker
).
to
receive
(
:perform_async
).
with
(
user
.
id
,
repository
.
id
)
delete_repository
(
repository
)
end
end
end
end
...
...
spec/controllers/projects/registry/tags_controller_spec.rb
View file @
97d0bf88
...
...
@@ -38,6 +38,11 @@ describe Projects::Registry::TagsController do
expect
(
response
).
to
match_response_schema
(
'registry/tags'
)
expect
(
response
).
to
include_pagination_headers
end
it
'tracks the event'
do
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
anything
,
'list_tags'
,
{})
get_tags
end
end
context
'when user can read the registry'
do
...
...
@@ -100,6 +105,12 @@ describe Projects::Registry::TagsController do
destroy_tag
(
'test.'
)
end
it
'tracks the event'
do
allow_any_instance_of
(
ContainerRegistry
::
Tag
).
to
receive
(
:delete
)
{
true
}
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
anything
,
'delete_tag'
,
{})
destroy_tag
(
'test.'
)
end
end
end
...
...
@@ -134,6 +145,13 @@ describe Projects::Registry::TagsController do
bulk_destroy_tags
(
tags
)
end
it
'tracks the event'
do
expect_delete_tags
(
tags
)
expect
(
Gitlab
::
Tracking
).
to
receive
(
:event
).
with
(
anything
,
'delete_tag_bulk'
,
{})
bulk_destroy_tags
(
tags
)
end
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