Sidebar Milestone - Fix wrong URL when selecting a parent group milestone
This commit is contained in:
parent
7530e4ec86
commit
379a6a709a
|
@ -56,7 +56,7 @@ export default class MilestoneSelect {
|
|||
|
||||
if (issueUpdateURL) {
|
||||
milestoneLinkTemplate = _.template(
|
||||
'<a href="/<%- full_path %>/milestones/<%- iid %>" class="bold has-tooltip" data-container="body" title="<%- remaining %>"><%- title %></a>',
|
||||
'<a href="<%- web_url %>" class="bold has-tooltip" data-container="body" title="<%- remaining %>"><%- title %></a>',
|
||||
);
|
||||
milestoneLinkNoneTemplate = '<span class="no-value">None</span>';
|
||||
}
|
||||
|
|
|
@ -412,6 +412,10 @@ module API
|
|||
expose :state, :created_at, :updated_at
|
||||
expose :due_date
|
||||
expose :start_date
|
||||
|
||||
expose :web_url do |milestone, _options|
|
||||
Gitlab::UrlBuilder.build(milestone)
|
||||
end
|
||||
end
|
||||
|
||||
class IssueBasic < ProjectEntity
|
||||
|
|
|
@ -26,6 +26,8 @@ module Gitlab
|
|||
project_snippet_url(object.project, object)
|
||||
when Snippet
|
||||
snippet_url(object)
|
||||
when Milestone
|
||||
milestone_url(object)
|
||||
else
|
||||
raise NotImplementedError.new("No URL builder defined for #{object.class}")
|
||||
end
|
||||
|
|
|
@ -13,7 +13,8 @@
|
|||
"created_at": { "type": "date" },
|
||||
"updated_at": { "type": "date" },
|
||||
"start_date": { "type": "date" },
|
||||
"due_date": { "type": "date" }
|
||||
"due_date": { "type": "date" },
|
||||
"web_url": { "type": "string" }
|
||||
},
|
||||
"required": [
|
||||
"id", "iid", "title", "description", "state",
|
||||
|
|
|
@ -22,6 +22,31 @@ describe Gitlab::UrlBuilder do
|
|||
end
|
||||
end
|
||||
|
||||
context 'when passing a Milestone' do
|
||||
let(:group) { create(:group) }
|
||||
let(:project) { create(:project, :public, namespace: group) }
|
||||
|
||||
context 'belonging to a project' do
|
||||
it 'returns a proper URL' do
|
||||
milestone = create(:milestone, project: project)
|
||||
|
||||
url = described_class.build(milestone)
|
||||
|
||||
expect(url).to eq "#{Settings.gitlab['url']}/#{milestone.project.full_path}/milestones/#{milestone.iid}"
|
||||
end
|
||||
end
|
||||
|
||||
context 'belonging to a group' do
|
||||
it 'returns a proper URL' do
|
||||
milestone = create(:milestone, group: group)
|
||||
|
||||
url = described_class.build(milestone)
|
||||
|
||||
expect(url).to eq "#{Settings.gitlab['url']}/groups/#{milestone.group.full_path}/-/milestones/#{milestone.iid}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when passing a MergeRequest' do
|
||||
it 'returns a proper URL' do
|
||||
merge_request = build_stubbed(:merge_request, iid: 42)
|
||||
|
|
Loading…
Reference in New Issue