Commit 8d568fe3 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'add_closed_at_attribute' into 'master'

Add 'closed_at' attribute to Issues API

Closes #5935

See merge request gitlab-org/gitlab-ce!14316
parents 9b137533 c0845e83
---
title: Add 'closed_at' attribute to Issues API
merge_request: 14316
author: Vitaliy @blackst0ne Klachkov
type: added
...@@ -95,6 +95,7 @@ Example response: ...@@ -95,6 +95,7 @@ Example response:
"username" : "root" "username" : "root"
}, },
"updated_at" : "2016-01-04T15:31:51.081Z", "updated_at" : "2016-01-04T15:31:51.081Z",
"closed_at" : null,
"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",
...@@ -205,6 +206,7 @@ Example response: ...@@ -205,6 +206,7 @@ Example response:
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z", "updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z", "created_at" : "2016-01-04T15:31:46.176Z",
"closed_at" : null,
"user_notes_count": 1, "user_notes_count": 1,
"due_date": null, "due_date": null,
"web_url": "http://example.com/example/example/issues/1", "web_url": "http://example.com/example/example/issues/1",
...@@ -311,6 +313,7 @@ Example response: ...@@ -311,6 +313,7 @@ Example response:
"title" : "Ut commodi ullam eos dolores perferendis nihil sunt.", "title" : "Ut commodi ullam eos dolores perferendis nihil sunt.",
"updated_at" : "2016-01-04T15:31:46.176Z", "updated_at" : "2016-01-04T15:31:46.176Z",
"created_at" : "2016-01-04T15:31:46.176Z", "created_at" : "2016-01-04T15:31:46.176Z",
"closed_at" : "2016-01-05T15:31:46.176Z",
"user_notes_count": 1, "user_notes_count": 1,
"due_date": "2016-07-22", "due_date": "2016-07-22",
"web_url": "http://example.com/example/example/issues/1", "web_url": "http://example.com/example/example/issues/1",
...@@ -358,7 +361,8 @@ Example response: ...@@ -358,7 +361,8 @@ Example response:
"id" : 11, "id" : 11,
"title" : "v3.0", "title" : "v3.0",
"created_at" : "2016-01-04T15:31:39.788Z", "created_at" : "2016-01-04T15:31:39.788Z",
"updated_at" : "2016-01-04T15:31:39.788Z" "updated_at" : "2016-01-04T15:31:39.788Z",
"closed_at" : "2016-01-05T15:31:46.176Z"
}, },
"author" : { "author" : {
"state" : "active", "state" : "active",
...@@ -465,6 +469,7 @@ Example response: ...@@ -465,6 +469,7 @@ Example response:
}, },
"description" : null, "description" : null,
"updated_at" : "2016-01-07T12:44:33.959Z", "updated_at" : "2016-01-07T12:44:33.959Z",
"closed_at" : null,
"milestone" : null, "milestone" : null,
"subscribed" : true, "subscribed" : true,
"user_notes_count": 0, "user_notes_count": 0,
...@@ -533,6 +538,7 @@ Example response: ...@@ -533,6 +538,7 @@ Example response:
"project_id" : 4, "project_id" : 4,
"description" : null, "description" : null,
"updated_at" : "2016-01-07T12:55:16.213Z", "updated_at" : "2016-01-07T12:55:16.213Z",
"closed_at" : "2016-01-08T12:55:16.213Z",
"iid" : 15, "iid" : 15,
"labels" : [ "labels" : [
"bug" "bug"
...@@ -615,6 +621,7 @@ Example response: ...@@ -615,6 +621,7 @@ Example response:
"state": "opened", "state": "opened",
"created_at": "2016-04-05T21:41:45.652Z", "created_at": "2016-04-05T21:41:45.652Z",
"updated_at": "2016-04-07T12:20:17.596Z", "updated_at": "2016-04-07T12:20:17.596Z",
"closed_at": null,
"labels": [], "labels": [],
"milestone": null, "milestone": null,
"assignees": [{ "assignees": [{
...@@ -692,6 +699,7 @@ Example response: ...@@ -692,6 +699,7 @@ Example response:
"state": "opened", "state": "opened",
"created_at": "2016-04-05T21:41:45.652Z", "created_at": "2016-04-05T21:41:45.652Z",
"updated_at": "2016-04-07T12:20:17.596Z", "updated_at": "2016-04-07T12:20:17.596Z",
"closed_at": null,
"labels": [], "labels": [],
"milestone": null, "milestone": null,
"assignees": [{ "assignees": [{
......
...@@ -332,6 +332,7 @@ module API ...@@ -332,6 +332,7 @@ module API
end end
class IssueBasic < ProjectEntity class IssueBasic < ProjectEntity
expose :closed_at
expose :labels do |issue, options| expose :labels do |issue, options|
# Avoids an N+1 query since labels are preloaded # Avoids an N+1 query since labels are preloaded
issue.labels.map(&:title).sort issue.labels.map(&:title).sort
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
"title": { "type": "string" }, "title": { "type": "string" },
"description": { "type": ["string", "null"] }, "description": { "type": ["string", "null"] },
"state": { "type": "string" }, "state": { "type": "string" },
"closed_at": { "type": "date" },
"created_at": { "type": "date" }, "created_at": { "type": "date" },
"updated_at": { "type": "date" }, "updated_at": { "type": "date" },
"labels": { "labels": {
......
...@@ -22,7 +22,8 @@ describe API::Issues, :mailer do ...@@ -22,7 +22,8 @@ describe API::Issues, :mailer do
state: :closed, state: :closed,
milestone: milestone, milestone: milestone,
created_at: generate(:past_time), created_at: generate(:past_time),
updated_at: 3.hours.ago updated_at: 3.hours.ago,
closed_at: 1.hour.ago
end end
let!(:confidential_issue) do let!(:confidential_issue) do
create :issue, create :issue,
...@@ -738,6 +739,7 @@ describe API::Issues, :mailer do ...@@ -738,6 +739,7 @@ describe API::Issues, :mailer do
expect(json_response['title']).to eq(issue.title) expect(json_response['title']).to eq(issue.title)
expect(json_response['description']).to eq(issue.description) expect(json_response['description']).to eq(issue.description)
expect(json_response['state']).to eq(issue.state) expect(json_response['state']).to eq(issue.state)
expect(json_response['closed_at']).to be_falsy
expect(json_response['created_at']).to be_present expect(json_response['created_at']).to be_present
expect(json_response['updated_at']).to be_present expect(json_response['updated_at']).to be_present
expect(json_response['labels']).to eq(issue.label_names) expect(json_response['labels']).to eq(issue.label_names)
...@@ -748,6 +750,13 @@ describe API::Issues, :mailer do ...@@ -748,6 +750,13 @@ describe API::Issues, :mailer do
expect(json_response['confidential']).to be_falsy expect(json_response['confidential']).to be_falsy
end end
it "exposes the 'closed_at' attribute" do
get api("/projects/#{project.id}/issues/#{closed_issue.iid}", user)
expect(response).to have_http_status(200)
expect(json_response['closed_at']).to be_present
end
context 'links exposure' do context 'links exposure' do
it 'exposes related resources full URIs' do it 'exposes related resources full URIs' do
get api("/projects/#{project.id}/issues/#{issue.iid}", user) get api("/projects/#{project.id}/issues/#{issue.iid}", user)
......
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