Commit aa910008 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Merge branch 'issue_11241' into 'master'

Expose web_url for epics on API

See merge request gitlab-org/gitlab!17380
parents 271f13f6 50590a05
---
title: Expose web_url for epics on API
merge_request: 17380
author:
type: added
......@@ -67,7 +67,7 @@ Example response:
"title": "Accusamus iste et ullam ratione voluptatem omnis debitis dolor est.",
"description": "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",
"state": "opened",
"web_edit_url": "http://localhost:3001/groups/test/-/epics/4",
"web_url": "http://localhost:3001/groups/test/-/epics/4",
"reference": "&4",
"author": {
"id": 10,
......@@ -122,7 +122,7 @@ Example response:
"title": "Ea cupiditate dolores ut vero consequatur quasi veniam voluptatem et non.",
"description": "Molestias dolorem eos vitae expedita impedit necessitatibus quo voluptatum.",
"state": "opened",
"web_edit_url": "http://localhost:3001/groups/test/-/epics/5",
"web_url": "http://localhost:3001/groups/test/-/epics/5",
"reference": "&5",
"author":{
"id": 7,
......@@ -188,7 +188,7 @@ Example response:
"title": "Epic",
"description": "Epic description",
"state": "opened",
"web_edit_url": "http://localhost:3001/groups/test/-/epics/6",
"web_url": "http://localhost:3001/groups/test/-/epics/5",
"reference": "&6",
"author": {
"name" : "Alexandra Bashirian",
......@@ -255,7 +255,7 @@ Example response:
"title": "New Title",
"description": "Epic description",
"state": "opened",
"web_edit_url": "http://localhost:3001/groups/test/-/epics/6",
"web_url": "http://localhost:3001/groups/test/-/epics/5",
"reference": "&6",
"author": {
"name" : "Alexandra Bashirian",
......
......@@ -77,7 +77,7 @@ module EE
reorder('relative_position ASC', 'id DESC')
end
scope :with_api_entity_associations, -> { preload(:author, :labels, :group) }
scope :with_api_entity_associations, -> { preload(:author, :labels, group: :route) }
MAX_HIERARCHY_DEPTH = 5
......
......@@ -294,9 +294,8 @@ module EE
expose :due_date_is_fixed?, as: :due_date_is_fixed, if: can_admin_epic
expose :due_date_fixed, :due_date_from_milestones, if: can_admin_epic
expose :state
expose :web_edit_url, if: can_admin_epic do |epic|
::Gitlab::Routing.url_helpers.group_epic_path(epic.group, epic)
end
expose :web_url, as: :web_edit_url, if: can_admin_epic # @deprecated
expose :web_url
expose :reference, if: { with_reference: true } do |epic|
epic.to_reference(full: true)
end
......@@ -322,6 +321,10 @@ module EE
epic.downvotes
end
end
def web_url
::Gitlab::Routing.url_helpers.group_epic_path(object.group, object)
end
end
class EpicIssue < ::API::Entities::Issue
......
......@@ -40,6 +40,7 @@
"created_at": { "type": ["string", "null"] },
"updated_at": { "type": ["string", "null"] },
"web_edit_url": { "type": "string" },
"web_url": { "type": "string" },
"reference": { "type": "string" }
},
"required": [
......
......@@ -65,6 +65,7 @@ describe API::Epics do
describe 'GET /groups/:id/epics' do
let(:url) { "/groups/#{group.path}/epics" }
let(:params) { { include_descendant_groups: true } }
it_behaves_like 'error requests'
......@@ -72,7 +73,7 @@ describe API::Epics do
before do
stub_licensed_features(epics: true)
get api(url, user)
get api(url, user), params: params
end
it 'returns 200 status' do
......@@ -87,15 +88,19 @@ describe API::Epics do
epic
# Avoid polluting queries with inserts for personal access token
pat = create(:personal_access_token, user: user)
subgroup_1 = create(:group, parent: group)
subgroup_2 = create(:group, parent: subgroup_1)
create(:epic, group: subgroup_1)
create(:epic, group: subgroup_2)
control = ActiveRecord::QueryRecorder.new(skip_cached: false) do
get api(url, personal_access_token: pat)
end
get api(url, personal_access_token: pat), params: params
end.count
label_2 = create(:label)
create_list(:labeled_epic, 2, group: group, labels: [label_2])
expect { get api(url, personal_access_token: pat) }.not_to exceed_all_query_limit(control)
expect { get api(url, personal_access_token: pat), params: params }.not_to exceed_all_query_limit(control)
expect(response).to have_gitlab_http_status(200)
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