diff --git a/lib/gitlab/client/project_releases.rb b/lib/gitlab/client/project_releases.rb index f9778b8fb..18f14b144 100644 --- a/lib/gitlab/client/project_releases.rb +++ b/lib/gitlab/client/project_releases.rb @@ -75,5 +75,16 @@ def update_project_release(project, tag_name, options = {}) def delete_project_release(project, tag_name) delete("/projects/#{url_encode project}/releases/#{tag_name}") end + + # Gets Latest Release + # + # @example + # Gitlab.project_latest_release(5) + # + # @param [Integer, String] project The ID or name of a project + # @return [Gitlab::ObjectifiedHash] Information about the release + def project_latest_release(project) + get("/projects/#{url_encode project}/releases/permalink/latest") + end end end diff --git a/spec/gitlab/client/project_releases_spec.rb b/spec/gitlab/client/project_releases_spec.rb index d230f66d1..43c07af1b 100644 --- a/spec/gitlab/client/project_releases_spec.rb +++ b/spec/gitlab/client/project_releases_spec.rb @@ -33,6 +33,21 @@ end end + describe '.project_latest_release' do + before do + stub_get('/projects/3/releases/permalink/latest', 'project_latest_release') + @project_latest_release = Gitlab.project_latest_release(3) + end + + it 'gets the correct resource' do + expect(a_get('/projects/3/releases/v0.1')).to have_been_made + end + + it 'returns information about a release' do + expect(@project_release.tag_name).to eq('v0.1') + end + end + describe '.create_project_release' do context 'without asset links' do before do