Commit aeddb74d authored by Patrick Derichs's avatar Patrick Derichs

EE Port of add task_completion_status to Taskable

Updates api documentation for all issues
and merge_requests related responses too.
parent 908a4c44
......@@ -75,4 +75,11 @@ module Taskable
def task_status_short
task_status(short: true)
end
def task_completion_status
@task_completion_status ||= {
count: tasks.summary.item_count,
completed_count: tasks.summary.complete_count
}
end
end
---
title: Add task count and completed count to responses of Issue and MR
merge_request: 28859
author:
type: added
......@@ -137,7 +137,11 @@ Example response:
"award_emoji":"http://example.com/api/v4/projects/1/issues/76/award_emoji",
"project":"http://example.com/api/v4/projects/1"
},
"subscribed": false
"subscribed": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -269,7 +273,11 @@ Example response:
"award_emoji":"http://example.com/api/v4/projects/4/issues/41/award_emoji",
"project":"http://example.com/api/v4/projects/4"
},
"subscribed": false
"subscribed": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -409,7 +417,11 @@ Example response:
"award_emoji":"http://example.com/api/v4/projects/4/issues/41/award_emoji",
"project":"http://example.com/api/v4/projects/4"
},
"subscribed": false
"subscribed": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -507,6 +519,10 @@ Example response:
"notes": "http://example.com/api/v4/projects/1/issues/2/notes",
"award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji",
"project": "http://example.com/api/v4/projects/1"
},
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -592,6 +608,10 @@ Example response:
"notes": "http://example.com/api/v4/projects/1/issues/2/notes",
"award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji",
"project": "http://example.com/api/v4/projects/1"
},
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -685,6 +705,10 @@ Example response:
"notes": "http://example.com/api/v4/projects/1/issues/2/notes",
"award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji",
"project": "http://example.com/api/v4/projects/1"
},
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -792,6 +816,10 @@ Example response:
"notes": "http://example.com/api/v4/projects/1/issues/2/notes",
"award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji",
"project": "http://example.com/api/v4/projects/1"
},
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -878,6 +906,10 @@ Example response:
"notes": "http://example.com/api/v4/projects/1/issues/2/notes",
"award_emoji": "http://example.com/api/v4/projects/1/issues/2/award_emoji",
"project": "http://example.com/api/v4/projects/1"
},
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -944,7 +976,11 @@ Example response:
"due_date": null,
"web_url": "http://example.com/example/example/issues/12",
"confidential": false,
"discussion_locked": false
"discussion_locked": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1042,8 +1078,11 @@ Example response:
"due_date": null,
"web_url": "http://example.com/example/example/issues/110",
"confidential": false,
"weight": null,
"discussion_locked": false
"discussion_locked": false,
"task_completion_status":{
"count":0,
"completed_count":0
}
},
"target_url": "https://gitlab.example.com/gitlab-org/gitlab-ci/issues/10",
"body": "Vel voluptas atque dicta mollitia adipisci qui at.",
......
......@@ -140,7 +140,10 @@ Parameters:
"human_total_time_spent": null
},
"squash": false,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -284,7 +287,10 @@ Parameters:
"human_total_time_spent": null
},
"squash": false,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -416,7 +422,10 @@ Parameters:
"human_total_time_spent": null
},
"squash": false,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
]
```
......@@ -552,7 +561,10 @@ Parameters:
},
"diverged_commits_count": 2,
"rebase_in_progress": false,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -586,7 +598,7 @@ Parameters:
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/10fc7f102be8de7657fb4d80898bbfe3?s=80&d=identicon",
"web_url": "http://localhost/user2"
},
}
]
```
......@@ -709,7 +721,11 @@ Parameters:
"total_time_spent": 0,
"human_time_estimate": null,
"human_total_time_spent": null
}
},
"task_completion_status":{
"count":0,
"completed_count":0
},
"changes": [
{
"old_path": "VERSION",
......@@ -882,7 +898,10 @@ order for it to take effect:
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1020,7 +1039,10 @@ Must include at least one non-required attribute from above.
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1174,7 +1196,10 @@ Parameters:
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1329,7 +1354,10 @@ Parameters:
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1365,7 +1393,7 @@ If the rebase operation is ongoing, the response will include the following:
```json
{
"rebase_in_progress": true
"rebase_in_progress": true,
"merge_error": null
}
```
......@@ -1376,7 +1404,7 @@ the following:
```json
{
"rebase_in_progress": false,
"merge_error": null,
"merge_error": null
}
```
......@@ -1385,7 +1413,7 @@ If the rebase operation fails, the response will include the following:
```json
{
"rebase_in_progress": false,
"merge_error": "Rebase failed. Please rebase locally",
"merge_error": "Rebase failed. Please rebase locally"
}
```
......@@ -1593,7 +1621,10 @@ Example response:
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......@@ -1723,7 +1754,10 @@ Example response:
"start_sha": "c380d3acebd181f13629a25d2e2acca46ffe1e00"
},
"diverged_commits_count": 2,
"approvals_before_merge": null
"task_completion_status":{
"count":0,
"completed_count":0
}
}
```
......
......@@ -576,6 +576,8 @@ module API
expose :time_stats, using: 'API::Entities::IssuableTimeStats' do |issue|
issue
end
expose :task_completion_status
end
class Issue < IssueBasic
......@@ -724,6 +726,8 @@ module API
end
expose :squash
expose :task_completion_status
end
class MergeRequest < MergeRequestBasic
......
# frozen_string_literal: true
require 'spec_helper'
describe 'task completion status response' do
set(:user) { create(:user) }
set(:project) do
create(:project, :public, creator_id: user.id, namespace: user.namespace)
end
shared_examples 'taskable completion status provider' do |path|
samples = [
{
description: '',
expected_count: 0,
expected_completed_count: 0
},
{
description: 'Lorem ipsum',
expected_count: 0,
expected_completed_count: 0
},
{
description: %{- [ ] task 1
- [x] task 2 },
expected_count: 2,
expected_completed_count: 1
},
{
description: %{- [ ] task 1
- [ ] task 2 },
expected_count: 2,
expected_completed_count: 0
},
{
description: %{- [x] task 1
- [x] task 2 },
expected_count: 2,
expected_completed_count: 2
},
{
description: %{- [ ] task 1},
expected_count: 1,
expected_completed_count: 0
},
{
description: %{- [x] task 1},
expected_count: 1,
expected_completed_count: 1
}
]
samples.each do |sample_data|
context "with a description of #{sample_data[:description].inspect}" do
before do
taskable.update!(description: sample_data[:description])
get api("#{path}?iids[]=#{taskable.iid}", user)
end
it { expect(response).to have_gitlab_http_status(200) }
it 'returns the expected results' do
expect(json_response).to be_an Array
expect(json_response).not_to be_empty
task_completion_status = json_response.first['task_completion_status']
expect(task_completion_status['count']).to eq(sample_data[:expected_count])
expect(task_completion_status['completed_count']).to eq(sample_data[:expected_completed_count])
end
end
end
end
context 'task list completion status for issues' do
it_behaves_like 'taskable completion status provider', '/issues' do
let(:taskable) { create(:issue, project: project, author: user) }
end
end
context 'task list completion status for merge_requests' do
it_behaves_like 'taskable completion status provider', '/merge_requests' do
let(:taskable) { create(:merge_request, source_project: project, target_project: project, author: user) }
end
end
end
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