summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-07-25 08:20:18 +0200
committerJarka Kadlecova <jarka@gitlab.com>2017-07-25 08:20:18 +0200
commit9b4aff19003e40ca28c864e18e9a33c3f02b4c64 (patch)
tree9b7f68a140995b1e70f667789f2691ce73486117
parentd964816b9fe56679ffc0b331e701f7b24db5c6a9 (diff)
downloadgitlab-ce-35481-milestone-link-fix.tar.gz
Fix milestones path from issues sidebar35481-milestone-link-fix
-rw-r--r--app/helpers/gitlab_routing_helper.rb6
-rw-r--r--app/views/shared/issuable/_sidebar.html.haml2
-rw-r--r--spec/helpers/gitlab_routing_helper_spec.rb16
3 files changed, 22 insertions, 2 deletions
diff --git a/app/helpers/gitlab_routing_helper.rb b/app/helpers/gitlab_routing_helper.rb
index 0517a699ae0..a37c5e6c51e 100644
--- a/app/helpers/gitlab_routing_helper.rb
+++ b/app/helpers/gitlab_routing_helper.rb
@@ -48,7 +48,11 @@ module GitlabRoutingHelper
end
def milestone_path(entity, *args)
- project_milestone_path(entity.project, entity, *args)
+ if entity.group
+ group_milestone_path(entity.group, entity, *args)
+ else
+ project_milestone_path(entity.project, entity, *args)
+ end
end
def issue_url(entity, *args)
diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml
index ecbaa901792..0e3ab6a76df 100644
--- a/app/views/shared/issuable/_sidebar.html.haml
+++ b/app/views/shared/issuable/_sidebar.html.haml
@@ -37,7 +37,7 @@
= link_to 'Edit', '#', class: 'edit-link pull-right'
.value.hide-collapsed
- if issuable.milestone
- = link_to issuable.milestone.title, project_milestone_path(@project, issuable.milestone), class: "bold has-tooltip", title: milestone_remaining_days(issuable.milestone), data: { container: "body", html: 1 }
+ = link_to issuable.milestone.title, milestone_path(issuable.milestone), class: "bold has-tooltip", title: milestone_remaining_days(issuable.milestone), data: { container: "body", html: 1 }
- else
%span.no-value None
diff --git a/spec/helpers/gitlab_routing_helper_spec.rb b/spec/helpers/gitlab_routing_helper_spec.rb
index 717ac1962d1..a463ab5bdf1 100644
--- a/spec/helpers/gitlab_routing_helper_spec.rb
+++ b/spec/helpers/gitlab_routing_helper_spec.rb
@@ -31,6 +31,22 @@ describe GitlabRoutingHelper do
it { expect(resend_invite_project_member_path(project_member)).to eq resend_invite_project_project_member_path(project_member.source, project_member) }
end
+
+ describe '#milestone_path' do
+ it 'returns path to a group milestone for group milestones' do
+ group = create(:group)
+ milestone = create(:milestone, group: group)
+
+ expect(milestone_path(milestone)).to eq("/groups/#{group.path}/milestones/#{milestone.iid}")
+ end
+
+ it 'returns path to a project milestone for non-group milestones' do
+ project = create(:empty_project)
+ milestone = create(:milestone, project: project)
+
+ expect(milestone_path(milestone)).to eq("/#{project.path_with_namespace}/milestones/#{milestone.iid}")
+ end
+ end
end
describe 'Group URL helpers' do