Commit 97d0bf88 authored by Giorgenes Gelatti's avatar Giorgenes Gelatti

Add tracking to registry repos

Add track_event() hooks to track package events
parent e3421799
......@@ -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 }
......
......@@ -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) }
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment