summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorMario de la Ossa <mariodelaossa@gmail.com>2018-06-12 16:40:16 -0600
committerMario de la Ossa <mariodelaossa@gmail.com>2018-06-12 17:22:12 -0600
commit379a6a709a55f952133354febddf97854c2d5d4d (patch)
tree7ff8d93b96395d80dd7bf58473bac7aafd54d250 /spec
parent7530e4ec86a686dede8eb8535fd231c1a75d3659 (diff)
downloadgitlab-ce-379a6a709a55f952133354febddf97854c2d5d4d.tar.gz
Sidebar Milestone - Fix wrong URL when selecting a parent group milestone47735-milestone-regression
Diffstat (limited to 'spec')
-rw-r--r--spec/fixtures/api/schemas/public_api/v4/milestones.json3
-rw-r--r--spec/lib/gitlab/url_builder_spec.rb25
2 files changed, 27 insertions, 1 deletions
diff --git a/spec/fixtures/api/schemas/public_api/v4/milestones.json b/spec/fixtures/api/schemas/public_api/v4/milestones.json
index c3c42b6ee60..448e97d6c85 100644
--- a/spec/fixtures/api/schemas/public_api/v4/milestones.json
+++ b/spec/fixtures/api/schemas/public_api/v4/milestones.json
@@ -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",
diff --git a/spec/lib/gitlab/url_builder_spec.rb b/spec/lib/gitlab/url_builder_spec.rb
index b81749cf428..9f495a5d50b 100644
--- a/spec/lib/gitlab/url_builder_spec.rb
+++ b/spec/lib/gitlab/url_builder_spec.rb
@@ -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)