Commit 12800e544527c08e3423ecabe4dffd5bef90e9d5
1 parent
ace9ff4a
Exists in
master
and in
4 other branches
Extend API Issues, MergeRequets, Milestones with iid field
Showing
4 changed files
with
16 additions
and
12 deletions
Show diff stats
lib/api/entities.rb
| @@ -91,15 +91,16 @@ module API | @@ -91,15 +91,16 @@ module API | ||
| 91 | expose :expires_at, :updated_at, :created_at | 91 | expose :expires_at, :updated_at, :created_at |
| 92 | end | 92 | end |
| 93 | 93 | ||
| 94 | - class Milestone < Grape::Entity | ||
| 95 | - expose :id | ||
| 96 | - expose (:project_id) {|milestone| milestone.project.id} | 94 | + class ProjectEntity < Grape::Entity |
| 95 | + expose :id, :iid | ||
| 96 | + expose (:project_id) { |entity| entity.project.id } | ||
| 97 | + end | ||
| 98 | + | ||
| 99 | + class Milestone < ProjectEntity | ||
| 97 | expose :title, :description, :due_date, :state, :updated_at, :created_at | 100 | expose :title, :description, :due_date, :state, :updated_at, :created_at |
| 98 | end | 101 | end |
| 99 | 102 | ||
| 100 | - class Issue < Grape::Entity | ||
| 101 | - expose :id | ||
| 102 | - expose (:project_id) {|issue| issue.project.id} | 103 | + class Issue < ProjectEntity |
| 103 | expose :title, :description | 104 | expose :title, :description |
| 104 | expose :label_list, as: :labels | 105 | expose :label_list, as: :labels |
| 105 | expose :milestone, using: Entities::Milestone | 106 | expose :milestone, using: Entities::Milestone |
| @@ -107,14 +108,14 @@ module API | @@ -107,14 +108,14 @@ module API | ||
| 107 | expose :state, :updated_at, :created_at | 108 | expose :state, :updated_at, :created_at |
| 108 | end | 109 | end |
| 109 | 110 | ||
| 110 | - class SSHKey < Grape::Entity | ||
| 111 | - expose :id, :title, :key, :created_at | 111 | + class MergeRequest < ProjectEntity |
| 112 | + expose :target_branch, :source_branch, :title, :state, :upvotes, :downvotes | ||
| 113 | + expose :author, :assignee, using: Entities::UserBasic | ||
| 114 | + expose :source_project_id, :target_project_id | ||
| 112 | end | 115 | end |
| 113 | 116 | ||
| 114 | - class MergeRequest < Grape::Entity | ||
| 115 | - expose :id, :target_branch, :source_branch, :title, :state, :upvotes, :downvotes | ||
| 116 | - expose :target_project_id, as: :project_id | ||
| 117 | - expose :author, :assignee, using: Entities::UserBasic | 117 | + class SSHKey < Grape::Entity |
| 118 | + expose :id, :title, :key, :created_at | ||
| 118 | end | 119 | end |
| 119 | 120 | ||
| 120 | class Note < Grape::Entity | 121 | class Note < Grape::Entity |
spec/requests/api/issues_spec.rb
| @@ -42,6 +42,7 @@ describe API::API do | @@ -42,6 +42,7 @@ describe API::API do | ||
| 42 | get api("/projects/#{project.id}/issues/#{issue.id}", user) | 42 | get api("/projects/#{project.id}/issues/#{issue.id}", user) |
| 43 | response.status.should == 200 | 43 | response.status.should == 200 |
| 44 | json_response['title'].should == issue.title | 44 | json_response['title'].should == issue.title |
| 45 | + json_response['iid'].should == issue.iid | ||
| 45 | end | 46 | end |
| 46 | 47 | ||
| 47 | it "should return 404 if issue id not found" do | 48 | it "should return 404 if issue id not found" do |
spec/requests/api/merge_requests_spec.rb
| @@ -34,6 +34,7 @@ describe API::API do | @@ -34,6 +34,7 @@ describe API::API do | ||
| 34 | get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user) | 34 | get api("/projects/#{project.id}/merge_request/#{merge_request.id}", user) |
| 35 | response.status.should == 200 | 35 | response.status.should == 200 |
| 36 | json_response['title'].should == merge_request.title | 36 | json_response['title'].should == merge_request.title |
| 37 | + json_response['iid'].should == merge_request.iid | ||
| 37 | end | 38 | end |
| 38 | 39 | ||
| 39 | it "should return a 404 error if merge_request_id not found" do | 40 | it "should return a 404 error if merge_request_id not found" do |
spec/requests/api/milestones_spec.rb
| @@ -30,6 +30,7 @@ describe API::API do | @@ -30,6 +30,7 @@ describe API::API do | ||
| 30 | get api("/projects/#{project.id}/milestones/#{milestone.id}", user) | 30 | get api("/projects/#{project.id}/milestones/#{milestone.id}", user) |
| 31 | response.status.should == 200 | 31 | response.status.should == 200 |
| 32 | json_response['title'].should == milestone.title | 32 | json_response['title'].should == milestone.title |
| 33 | + json_response['iid'].should == milestone.iid | ||
| 33 | end | 34 | end |
| 34 | 35 | ||
| 35 | it "should return 401 error if user not authenticated" do | 36 | it "should return 401 error if user not authenticated" do |