Commit bbd3fcf7 authored by David Fernandez's avatar David Fernandez

Do not track `list_repositories` twice

parent c976db76
......@@ -7,13 +7,13 @@ module Groups
before_action :feature_flag_group_container_registry_browser!
def index
track_event(:list_repositories)
respond_to do |format|
format.html
format.json do
@images = group.container_repositories.with_api_entity_associations
track_event(:list_repositories)
render json: ContainerRepositoriesSerializer
.new(current_user: current_user)
.represent_read_only(@images)
......
......@@ -7,12 +7,13 @@ module Projects
before_action :ensure_root_container_repository!, only: [:index]
def index
@images = project.container_repositories
track_event(:list_repositories)
respond_to do |format|
format.html
format.json do
@images = project.container_repositories
track_event(:list_repositories)
render json: ContainerRepositoriesSerializer
.new(project: project, current_user: current_user)
.represent(@images)
......
......@@ -17,6 +17,8 @@ describe Groups::Registry::RepositoriesController do
context 'GET #index' do
context 'when container registry is enabled' do
it 'show index page' do
expect(Gitlab::Tracking).not_to receive(:event)
get :index, params: {
group_id: group
}
......@@ -54,7 +56,8 @@ describe Groups::Registry::RepositoriesController do
expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_repositories', {})
get :index, params: {
group_id: group
group_id: group,
format: :json
}
end
end
......
......@@ -35,6 +35,8 @@ describe Projects::Registry::RepositoriesController do
end
it 'successfully renders container repositories' do
expect(Gitlab::Tracking).not_to receive(:event)
go_to_index
expect(response).to have_gitlab_http_status(:ok)
......@@ -43,7 +45,7 @@ describe Projects::Registry::RepositoriesController do
it 'tracks the event' do
expect(Gitlab::Tracking).to receive(:event).with(anything, 'list_repositories', {})
go_to_index
go_to_index(format: :json)
end
it 'creates a root container repository' do
......
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