summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiorgenes Gelatti <ggelatti@gitlab.com>2019-09-05 15:44:35 +1000
committerGiorgenes Gelatti <ggelatti@gitlab.com>2019-09-05 15:44:35 +1000
commitfddb01c012831f917bb30decc499ba4140d5e44c (patch)
treebea08ecb558f013f57adf0917f8ba35b0bac8521
parent87ba7fb5812bdd32a02b06c5df68a46d1ab8f80c (diff)
downloadgitlab-ce-fddb01c012831f917bb30decc499ba4140d5e44c.tar.gz
Add tracking to registry tags
-rw-r--r--app/controllers/projects/registry/tags_controller.rb9
-rw-r--r--spec/controllers/projects/registry/tags_controller_spec.rb19
2 files changed, 28 insertions, 0 deletions
diff --git a/app/controllers/projects/registry/tags_controller.rb b/app/controllers/projects/registry/tags_controller.rb
index 54e2faa2dd7..ecc00d825c2 100644
--- a/app/controllers/projects/registry/tags_controller.rb
+++ b/app/controllers/projects/registry/tags_controller.rb
@@ -8,6 +8,7 @@ module Projects
LIMIT = 15
def index
+ track(:list_tags)
respond_to do |format|
format.json do
render json: ContainerTagsSerializer
@@ -20,6 +21,8 @@ module Projects
def destroy
if tag.delete
+ track(:delete_tag)
+
respond_to do |format|
format.json { head :no_content }
end
@@ -48,9 +51,11 @@ module Projects
return
end
+ track(:delete_tag_bulk)
success_count = 0
@tags.each do |tag|
if tag.delete
+ track(:delete_tag)
success_count += 1
end
end
@@ -62,6 +67,10 @@ module Projects
private
+ def track(action)
+ Gitlab::Tracking.event('Projects::Registry::TagsController', action.to_s)
+ end
+
def tags
Kaminari::PaginatableArray.new(image.tags, limit: LIMIT)
end
diff --git a/spec/controllers/projects/registry/tags_controller_spec.rb b/spec/controllers/projects/registry/tags_controller_spec.rb
index c6e063d8229..d90b8c0cf23 100644
--- a/spec/controllers/projects/registry/tags_controller_spec.rb
+++ b/spec/controllers/projects/registry/tags_controller_spec.rb
@@ -36,6 +36,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
@@ -98,6 +103,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
@@ -131,6 +142,14 @@ describe Projects::Registry::TagsController do
bulk_destroy_tags(['rc1', 'test.'])
end
+
+ it 'tracks the event' do
+ allow_any_instance_of(ContainerRegistry::Tag).to receive(:delete) { |*args| ContainerRegistry::Tag.delete(*args) }
+ expect(ContainerRegistry::Tag).to receive(:delete).exactly(2).times
+ expect(Gitlab::Tracking).to receive(:event).with(anything, 'delete_tag_bulk')
+
+ bulk_destroy_tags(['rc1', 'test.'])
+ end
end
end