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