Commit 4c8942f9 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Replace `full_path`, `path` & `web_url` with a single `relative_path`

parent 1fb49b87
...@@ -2,7 +2,7 @@ class GroupChildEntity < Grape::Entity ...@@ -2,7 +2,7 @@ class GroupChildEntity < Grape::Entity
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
include RequestAwareEntity include RequestAwareEntity
expose :id, :name, :path, :description, :visibility, :full_name, :full_path, :web_url, expose :id, :name, :description, :visibility, :full_name, :relative_path,
:created_at, :updated_at, :can_edit, :type, :avatar_url, :permission, :edit_path :created_at, :updated_at, :can_edit, :type, :avatar_url, :permission, :edit_path
def project? def project?
...@@ -31,6 +31,14 @@ class GroupChildEntity < Grape::Entity ...@@ -31,6 +31,14 @@ class GroupChildEntity < Grape::Entity
end end
end end
def relative_path
if project?
project_path(object)
else
group_path(object)
end
end
def permission def permission
return unless request&.current_user return unless request&.current_user
......
...@@ -16,19 +16,17 @@ describe GroupChildEntity do ...@@ -16,19 +16,17 @@ describe GroupChildEntity do
end end
%w[id %w[id
path
full_name full_name
full_path
avatar_url avatar_url
name name
description description
web_url
visibility visibility
type type
can_edit can_edit
visibility visibility
edit_path edit_path
permission].each do |attribute| permission
relative_path].each do |attribute|
it "includes #{attribute}" do it "includes #{attribute}" do
expect(json[attribute.to_sym]).to be_present expect(json[attribute.to_sym]).to be_present
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