Commit 11b05f06 authored by Robert Speicher's avatar Robert Speicher

Merge branch '10io-fix-container-repositories-index-tracking' into 'master'

Do not track `list_repositories` twice

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