Commit ba34045f authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Expose release notes to tags api

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent c119a737
...@@ -112,6 +112,12 @@ module API ...@@ -112,6 +112,12 @@ module API
options[:project].repository.commit(repo_obj.target) options[:project].repository.commit(repo_obj.target)
end end
end end
expose :release do |repo_obj, options|
if options[:project]
options[:project].releases.find_by(tag: repo_obj.name)
end
end
end end
class RepoObject < Grape::Entity class RepoObject < Grape::Entity
......
...@@ -12,11 +12,31 @@ describe API::API, api: true do ...@@ -12,11 +12,31 @@ describe API::API, api: true do
let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) } let!(:guest) { create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST) }
describe "GET /projects/:id/repository/tags" do describe "GET /projects/:id/repository/tags" do
let(:tag_name) { project.repository.tag_names.sort.reverse.first }
let(:description) { 'Awesome release!' }
context 'without releases' do
it "should return an array of project tags" do it "should return an array of project tags" do
get api("/projects/#{project.id}/repository/tags", user) get api("/projects/#{project.id}/repository/tags", user)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response).to be_an Array expect(json_response).to be_an Array
expect(json_response.first['name']).to eq(project.repo.tags.sort_by(&:name).reverse.first.name) expect(json_response.first['name']).to eq(tag_name)
end
end
context 'with releases' do
before do
release = project.releases.find_or_initialize_by(tag: tag_name)
release.update_attributes(description: description)
get api("/projects/#{project.id}/repository/tags", user)
end
it "should return an array of project tags with release info" do
expect(response.status).to eq(200)
expect(json_response).to be_an Array
expect(json_response.first['name']).to eq(tag_name)
expect(json_response.first['release']['description']).to eq(description)
end
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