Commit 341a2887 authored by Lee Tickett's avatar Lee Tickett Committed by Heinrich Lee Yu

Expose moved_to in issues api

parent afadba04
---
title: Expose moved_to_id in issues API
merge_request: 20083
author: Lee Tickett
type: added
...@@ -113,6 +113,7 @@ Example response: ...@@ -113,6 +113,7 @@ Example response:
"id" : 76, "id" : 76,
"title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.", "title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.",
"created_at" : "2016-01-04T15:31:51.081Z", "created_at" : "2016-01-04T15:31:51.081Z",
"moved_to_id" : null,
"iid" : 6, "iid" : 6,
"labels" : ["foo", "bar"], "labels" : ["foo", "bar"],
"upvotes": 4, "upvotes": 4,
......
...@@ -660,6 +660,8 @@ module API ...@@ -660,6 +660,8 @@ module API
expose :subscribed, if: -> (_, options) { options.fetch(:include_subscribed, true) } do |issue, options| expose :subscribed, if: -> (_, options) { options.fetch(:include_subscribed, true) } do |issue, options|
issue.subscribed?(options[:current_user], options[:project] || issue.project) issue.subscribed?(options[:current_user], options[:project] || issue.project)
end end
expose :moved_to_id
end end
class IssuableTimeStats < Grape::Entity class IssuableTimeStats < Grape::Entity
......
...@@ -589,6 +589,24 @@ describe API::Issues do ...@@ -589,6 +589,24 @@ describe API::Issues do
expect(json_response['subscribed']).to be_truthy expect(json_response['subscribed']).to be_truthy
end end
context "moved_to_id" do
let(:moved_issue) do
create(:closed_issue, project: project, moved_to: issue)
end
it 'returns null when not moved' do
get api("/projects/#{project.id}/issues/#{issue.iid}", user)
expect(json_response['moved_to_id']).to be_nil
end
it 'returns issue id when moved' do
get api("/projects/#{project.id}/issues/#{moved_issue.iid}", user)
expect(json_response['moved_to_id']).to eq(issue.id)
end
end
it 'exposes the closed_at attribute' do it 'exposes the closed_at attribute' do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user) get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user)
......
...@@ -832,7 +832,7 @@ describe API::Issues do ...@@ -832,7 +832,7 @@ describe API::Issues do
end end
context 'when issue does not exist' do context 'when issue does not exist' do
it 'returns 404 when trying to move an issue' do it 'returns 404 when trying to delete an issue' do
delete api("/projects/#{project.id}/issues/123", user) delete api("/projects/#{project.id}/issues/123", user)
expect(response).to have_gitlab_http_status(404) expect(response).to have_gitlab_http_status(404)
......
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