Commit 126bb14e authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'bug-incorrect-issue-url-in-vsa' into 'master'

Fix URLs of issues in VSA dashboard

Closes #225625

See merge request gitlab-org/gitlab!38703
parents 289cc8a8 b8e0ba1b
---
title: Fix URLs of issues in VSA dashboard
merge_request: 38703
author:
type: fixed
......@@ -13,7 +13,7 @@ module Gitlab
MAPPINGS = {
Issue => {
serializer_class: AnalyticsIssueSerializer,
includes_for_query: { project: [:namespace], author: [] },
includes_for_query: { project: { namespace: [:route] }, author: [] },
columns_for_select: %I[title iid id created_at author_id project_id]
},
MergeRequest => {
......@@ -41,7 +41,7 @@ module Gitlab
project = record.project
attributes = record.attributes.merge({
project_path: project.path,
namespace_path: project.namespace.path,
namespace_path: project.namespace.route.path,
author: record.author
})
serializer.represent(attributes)
......
......@@ -17,16 +17,13 @@ RSpec.describe AnalyticsIssueEntity do
}
end
let(:project) { create(:project, name: 'my project') }
let(:request) { EntityRequest.new(entity: :merge_request) }
let(:entity) do
described_class.new(entity_hash, request: request, project: project)
end
context 'generic entity' do
subject { entity.as_json }
shared_examples 'generic entity' do
it 'contains the entity URL' do
expect(subject).to include(:url)
end
......@@ -40,4 +37,24 @@ RSpec.describe AnalyticsIssueEntity do
expect(subject).not_to include(/variables/)
end
end
context 'without subgroup' do
let_it_be(:project) { create(:project, name: 'my project') }
subject { entity.as_json }
it_behaves_like 'generic entity'
end
context 'with subgroup' do
let_it_be(:project) { create(:project, :in_subgroup, name: 'my project') }
subject { entity.as_json }
it_behaves_like 'generic entity'
it 'has URL containing subgroup' do
expect(subject[:url]).to include("#{project.group.parent.name}/#{project.group.name}/my_project/")
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