Commit 222b6c80 authored by Nathan Friend's avatar Nathan Friend Committed by Heinrich Lee Yu

Add _links.self to Release API endpoints

This commit adds a new property, _links.self, to two Release API
endpoints.
parent ff36348d
...@@ -19,6 +19,12 @@ class ReleasePresenter < Gitlab::View::Presenter::Delegated ...@@ -19,6 +19,12 @@ class ReleasePresenter < Gitlab::View::Presenter::Delegated
project_tag_path(project, release.tag) project_tag_path(project, release.tag)
end end
def self_url
return unless ::Feature.enabled?(:release_show_page, project)
project_release_url(project, release)
end
def merge_requests_url def merge_requests_url
return unless release_mr_issue_urls_available? return unless release_mr_issue_urls_available?
......
...@@ -1101,6 +1101,7 @@ module API ...@@ -1101,6 +1101,7 @@ module API
expose :evidence_file_path, expose_nil: false, if: ->(_, _) { can_download_code? } expose :evidence_file_path, expose_nil: false, if: ->(_, _) { can_download_code? }
end end
expose :_links do expose :_links do
expose :self_url, as: :self, expose_nil: false
expose :merge_requests_url, expose_nil: false expose :merge_requests_url, expose_nil: false
expose :issues_url, expose_nil: false expose :issues_url, expose_nil: false
expose :edit_url, expose_nil: false expose :edit_url, expose_nil: false
......
...@@ -51,6 +51,22 @@ describe ReleasePresenter do ...@@ -51,6 +51,22 @@ describe ReleasePresenter do
end end
end end
describe '#self_url' do
subject { presenter.self_url }
it 'returns its own url' do
is_expected.to match /#{project_release_url(project, release)}/
end
context 'when release_show_page feature flag is disabled' do
before do
stub_feature_flags(release_show_page: false)
end
it { is_expected.to be_nil }
end
end
describe '#merge_requests_url' do describe '#merge_requests_url' do
subject { presenter.merge_requests_url } subject { presenter.merge_requests_url }
......
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