Commit b5d1a632 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '349612-expose-iteration-number-via-apis' into 'master'

Expose iteration ordinal number via APIs

See merge request gitlab-org/gitlab!77650
parents 983eadcf a3806d20
......@@ -11549,6 +11549,7 @@ Represents an iteration object.
| <a id="iterationreport"></a>`report` | [`TimeboxReport`](#timeboxreport) | Historically accurate report about the timebox. |
| <a id="iterationscopedpath"></a>`scopedPath` | [`String`](#string) | Web path of the iteration, scoped to the query parent. Only valid for Project parents. Returns null in other contexts. |
| <a id="iterationscopedurl"></a>`scopedUrl` | [`String`](#string) | Web URL of the iteration, scoped to the query parent. Only valid for Project parents. Returns null in other contexts. |
| <a id="iterationsequence"></a>`sequence` | [`Int!`](#int) | Sequence number for the iteration when you sort the containing cadence's iterations by the start and end date. The earliest starting and ending iteration is assigned 1. |
| <a id="iterationstartdate"></a>`startDate` | [`Time`](#time) | Timestamp of the iteration start date. |
| <a id="iterationstate"></a>`state` | [`IterationState!`](#iterationstate) | State of the iteration. |
| <a id="iterationtitle"></a>`title` | [`String!`](#string) | Title of the iteration. |
......@@ -43,6 +43,7 @@ Example response:
{
"id": 53,
"iid": 13,
"sequence": 1,
"group_id": 5,
"title": "Iteration II",
"description": "Ipsum Lorem ipsum",
......
......@@ -17,6 +17,9 @@ module Types
field :iid, GraphQL::Types::ID, null: false,
description: 'Internal ID of the iteration.'
field :sequence, GraphQL::Types::Int, null: false,
description: "Sequence number for the iteration when you sort the containing cadence's iterations by the start and end date. The earliest starting and ending iteration is assigned 1."
field :title, GraphQL::Types::String, null: false,
description: 'Title of the iteration.'
......
......@@ -4,6 +4,7 @@ module API
module Entities
class Iteration < Grape::Entity
expose :id, :iid
expose :sequence
expose :project_id, if: -> (entity, options) { entity&.project_id }
expose :group_id, if: -> (entity, options) { entity&.group_id }
expose :title, :description
......
......@@ -9,7 +9,7 @@ RSpec.describe GitlabSchema.types['Iteration'] do
it 'has the expected fields' do
expected_fields = %w[
id id title description state web_path web_url scoped_path scoped_url
id iid sequence title description state web_path web_url scoped_path scoped_url
due_date start_date created_at updated_at report iteration_cadence
]
......
......@@ -25,12 +25,13 @@ RSpec.describe API::Iterations do
end
context 'when user has access' do
it 'returns a list of iterations' do
it 'returns a list of iterations', :aggregate_failures do
get api(api_path, user)
expect(response).to have_gitlab_http_status(:ok)
expect(json_response.size).to eq(3)
expect(json_response.map { |i| i['id'] }).to contain_exactly(current_iteration.id, closed_iteration.id, ancestor_iteration.id)
expect(json_response.map { |i| i['sequence'] } ).to contain_exactly(current_iteration.sequence, closed_iteration.sequence, ancestor_iteration.sequence)
end
context 'filter by iteration state' do
......
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