Commit 0a0c0617 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'expose_moved_to_in_issues_api' into 'master'

Expose moved_to in issues api

Closes #36554 and #31443

See merge request gitlab-org/gitlab!20083
parents afadba04 341a2887
---
title: Expose moved_to_id in issues API
merge_request: 20083
author: Lee Tickett
type: added
......@@ -113,6 +113,7 @@ Example response:
"id" : 76,
"title" : "Consequatur vero maxime deserunt laboriosam est voluptas dolorem.",
"created_at" : "2016-01-04T15:31:51.081Z",
"moved_to_id" : null,
"iid" : 6,
"labels" : ["foo", "bar"],
"upvotes": 4,
......
......@@ -660,6 +660,8 @@ module API
expose :subscribed, if: -> (_, options) { options.fetch(:include_subscribed, true) } do |issue, options|
issue.subscribed?(options[:current_user], options[:project] || issue.project)
end
expose :moved_to_id
end
class IssuableTimeStats < Grape::Entity
......
......@@ -589,6 +589,24 @@ describe API::Issues do
expect(json_response['subscribed']).to be_truthy
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
get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user)
......
......@@ -832,7 +832,7 @@ describe API::Issues do
end
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)
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