Commit 12800e54 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Extend API Issues, MergeRequets, Milestones with iid field

parent ace9ff4a
...@@ -91,15 +91,16 @@ module API ...@@ -91,15 +91,16 @@ module API
expose :expires_at, :updated_at, :created_at expose :expires_at, :updated_at, :created_at
end end
class Milestone < Grape::Entity class ProjectEntity < Grape::Entity
expose :id expose :id, :iid
expose (:project_id) {|milestone| milestone.project.id} expose (:project_id) { |entity| entity.project.id }
end
class Milestone < ProjectEntity
expose :title, :description, :due_date, :state, :updated_at, :created_at expose :title, :description, :due_date, :state, :updated_at, :created_at
end end
class Issue < Grape::Entity class Issue < ProjectEntity
expose :id
expose (:project_id) {|issue| issue.project.id}
expose :title, :description expose :title, :description
expose :label_list, as: :labels expose :label_list, as: :labels
expose :milestone, using: Entities::Milestone expose :milestone, using: Entities::Milestone
...@@ -107,14 +108,14 @@ module API ...@@ -107,14 +108,14 @@ module API
expose :state, :updated_at, :created_at expose :state, :updated_at, :created_at
end end
class SSHKey < Grape::Entity class MergeRequest < ProjectEntity
expose :id, :title, :key, :created_at expose :target_branch, :source_branch, :title, :state, :upvotes, :downvotes
expose :author, :assignee, using: Entities::UserBasic
expose :source_project_id, :target_project_id
end end
class MergeRequest < Grape::Entity class SSHKey < Grape::Entity
expose :id, :target_branch, :source_branch, :title, :state, :upvotes, :downvotes expose :id, :title, :key, :created_at
expose :target_project_id, as: :project_id
expose :author, :assignee, using: Entities::UserBasic
end end
class Note < Grape::Entity class Note < Grape::Entity
......
...@@ -42,6 +42,7 @@ describe API::API do ...@@ -42,6 +42,7 @@ describe API::API do
get api("/projects/#{project.id}/issues/#{issue.id}", user) get api("/projects/#{project.id}/issues/#{issue.id}", user)
response.status.should == 200 response.status.should == 200
json_response['title'].should == issue.title json_response['title'].should == issue.title
json_response['iid'].should == issue.iid
end end
it "should return 404 if issue id not found" do it "should return 404 if issue id not found" do
......
...@@ -34,6 +34,7 @@ describe API::API do ...@@ -34,6 +34,7 @@ describe API::API do
get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user) get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user)
response.status.should == 200 response.status.should == 200
json_response['title'].should == merge_request.title json_response['title'].should == merge_request.title
json_response['iid'].should == merge_request.iid
end end
it "should return a 404 error if merge_request_id not found" do it "should return a 404 error if merge_request_id not found" do
......
...@@ -30,6 +30,7 @@ describe API::API do ...@@ -30,6 +30,7 @@ describe API::API do
get api("/projects/#{project.id}/milestones/#{milestone.id}", user) get api("/projects/#{project.id}/milestones/#{milestone.id}", user)
response.status.should == 200 response.status.should == 200
json_response['title'].should == milestone.title json_response['title'].should == milestone.title
json_response['iid'].should == milestone.iid
end end
it "should return 401 error if user not authenticated" do it "should return 401 error if user not authenticated" do
......
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