Commit 50590a05 authored by Felipe Artur's avatar Felipe Artur

Turn web_url into a method

parent 90ee3199
--- ---
title: Expose web_url for epics on API title: Expose web_url for epics on API
merge_request: merge_request: 17380
author: author:
type: changed type: added
...@@ -241,8 +241,6 @@ module EE ...@@ -241,8 +241,6 @@ module EE
class Epic < Grape::Entity class Epic < Grape::Entity
can_admin_epic = ->(epic, opts) { Ability.allowed?(opts[:user], :admin_epic, epic) } can_admin_epic = ->(epic, opts) { Ability.allowed?(opts[:user], :admin_epic, epic) }
epic_url = ->(epic) { ::Gitlab::Routing.url_helpers.group_epic_path(epic.group, epic) }
expose :id expose :id
expose :iid expose :iid
expose :group_id expose :group_id
...@@ -258,14 +256,8 @@ module EE ...@@ -258,14 +256,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
epic_url.call(epic) expose :web_url
end
# web_edit_url is already exposed and has the same value of web_url
# this field has been added again with other name to be consistent with other API responses
expose :web_url do |epic|
epic_url.call(epic)
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
...@@ -291,6 +283,10 @@ module EE ...@@ -291,6 +283,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
......
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