Commit 7e636b9b authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch 'nfriend-add-upcoming-release-to-graphql' into 'master'

Add release `upcoming_release` field to GraphQL

See merge request gitlab-org/gitlab!41183
parents 2f1453fa c97c2a6e
......@@ -28,6 +28,8 @@ module Types
description: 'Timestamp of when the release was created'
field :released_at, Types::TimeType, null: true,
description: 'Timestamp of when the release was released'
field :upcoming_release, GraphQL::BOOLEAN_TYPE, null: true, method: :upcoming_release?,
description: 'Indicates the release is an upcoming release'
field :assets, Types::ReleaseAssetsType, null: true, method: :itself,
description: 'Assets of the release'
field :links, Types::ReleaseLinksType, null: true, method: :itself,
......
---
title: Add "upcomingRelease" field to GraphQL endpoint
merge_request: 41183
author:
type: added
......@@ -14358,6 +14358,11 @@ type Release {
Relative web path to the tag associated with the release
"""
tagPath: String
"""
Indicates the release is an upcoming release
"""
upcomingRelease: Boolean
}
"""
......
......@@ -41832,6 +41832,20 @@
},
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "upcomingRelease",
"description": "Indicates the release is an upcoming release",
"args": [
],
"type": {
"kind": "SCALAR",
"name": "Boolean",
"ofType": null
},
"isDeprecated": false,
"deprecationReason": null
}
],
"inputFields": null,
......@@ -1959,6 +1959,7 @@ Represents a release
| `releasedAt` | Time | Timestamp of when the release was released |
| `tagName` | String | Name of the tag associated with the release |
| `tagPath` | String | Relative web path to the tag associated with the release |
| `upcomingRelease` | Boolean | Indicates the release is an upcoming release |
### ReleaseAssetLink
......
......@@ -11,6 +11,7 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
let_it_be(:reporter) { create(:user) }
let_it_be(:stranger) { create(:user) }
let_it_be(:link_filepath) { '/direct/asset/link/path' }
let_it_be(:released_at) { Time.now - 1.day }
let(:params_for_issues_and_mrs) { { scope: 'all', state: 'opened', release_tag: release.tag } }
let(:post_query) { post_graphql(query, current_user: current_user) }
......@@ -39,6 +40,7 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
name
createdAt
releasedAt
upcomingRelease
})
end
......@@ -54,7 +56,8 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
'descriptionHtml' => release.description_html,
'name' => release.name,
'createdAt' => release.created_at.iso8601,
'releasedAt' => release.released_at.iso8601
'releasedAt' => release.released_at.iso8601,
'upcomingRelease' => false
})
end
end
......@@ -270,7 +273,7 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
let_it_be(:project) { create(:project, :repository, :private) }
let_it_be(:milestone_1) { create(:milestone, project: project) }
let_it_be(:milestone_2) { create(:milestone, project: project) }
let_it_be(:release) { create(:release, :with_evidence, project: project, milestones: [milestone_1, milestone_2]) }
let_it_be(:release) { create(:release, :with_evidence, project: project, milestones: [milestone_1, milestone_2], released_at: released_at) }
let_it_be(:release_link_1) { create(:release_link, release: release) }
let_it_be(:release_link_2) { create(:release_link, release: release, filepath: link_filepath) }
......@@ -311,7 +314,7 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
let_it_be(:project) { create(:project, :repository, :public) }
let_it_be(:milestone_1) { create(:milestone, project: project) }
let_it_be(:milestone_2) { create(:milestone, project: project) }
let_it_be(:release) { create(:release, :with_evidence, project: project, milestones: [milestone_1, milestone_2]) }
let_it_be(:release) { create(:release, :with_evidence, project: project, milestones: [milestone_1, milestone_2], released_at: released_at) }
let_it_be(:release_link_1) { create(:release_link, release: release) }
let_it_be(:release_link_2) { create(:release_link, release: release, filepath: link_filepath) }
......@@ -373,4 +376,45 @@ RSpec.describe 'Query.project(fullPath).release(tagName)' do
it_behaves_like 'no access to the release field'
end
end
describe 'upcoming release' do
let(:path) { path_prefix }
let(:project) { create(:project, :repository, :private) }
let(:release) { create(:release, :with_evidence, project: project, released_at: released_at) }
let(:current_user) { developer }
let(:release_fields) do
query_graphql_field(%{
releasedAt
upcomingRelease
})
end
before do
project.add_developer(developer)
post_query
end
context 'future release' do
let(:released_at) { Time.now + 1.day }
it 'finds all release data' do
expect(data).to eq({
'releasedAt' => release.released_at.iso8601,
'upcomingRelease' => true
})
end
end
context 'past release' do
let(:released_at) { Time.now - 1.day }
it 'finds all release data' do
expect(data).to eq({
'releasedAt' => release.released_at.iso8601,
'upcomingRelease' => false
})
end
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