Commit 52b83989 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch '275818-be-add-info-error-messages-to-security-widget-summary-diverged' into 'master'

Add divergedFromTargetBranch to MergeRequestType

See merge request gitlab-org/gitlab!53759
parents 4f838cf8 648b852e
......@@ -108,6 +108,10 @@ module Types
null: false, calls_gitaly: true,
method: :target_branch_exists?,
description: 'Indicates if the target branch of the merge request exists.'
field :diverged_from_target_branch, GraphQL::BOOLEAN_TYPE,
null: false, calls_gitaly: true,
method: :diverged_from_target_branch?,
description: 'Indicates if the source branch is behind the target branch.'
field :mergeable_discussions_state, GraphQL::BOOLEAN_TYPE, null: true,
description: 'Indicates if all discussions in the merge request have been resolved, allowing the merge request to be merged.'
field :web_url, GraphQL::STRING_TYPE, null: true,
......
---
title: Add divergedFromTargetBranch field to MergeRequestType to indicate the target
branch has diverged from the source branch
merge_request: 53759
author:
type: changed
......@@ -2618,6 +2618,7 @@ Autogenerated return type of MarkAsSpamSnippet.
| `diffStatsSummary` | DiffStatsSummary | Summary of which files were changed in this merge request. |
| `discussionLocked` | Boolean! | Indicates if comments on the merge request are locked to members only. |
| `discussions` | DiscussionConnection! | All discussions on this noteable. |
| `divergedFromTargetBranch` | Boolean! | Indicates if the source branch is behind the target branch. |
| `downvotes` | Int! | Number of downvotes for the merge request. |
| `forceRemoveSourceBranch` | Boolean | Indicates if the project settings will lead to source branch deletion after merge. |
| `hasCi` | Boolean! | Indicates if the merge request has CI. |
......
......@@ -23,7 +23,7 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
merge_error allow_collaboration should_be_rebased rebase_commit_sha
rebase_in_progress default_merge_commit_message
merge_ongoing mergeable_discussions_state web_url
source_branch_exists target_branch_exists
source_branch_exists target_branch_exists diverged_from_target_branch
upvotes downvotes head_pipeline pipelines task_completion_status
milestone assignees reviewers participants subscribed labels discussion_locked time_estimate
total_time_spent reference author merged_at commit_count current_user_todos
......@@ -77,4 +77,33 @@ RSpec.describe GitlabSchema.types['MergeRequest'] do
end
end
end
describe '#diverged_from_target_branch' do
subject(:execute_query) { GitlabSchema.execute(query, context: { current_user: current_user }).as_json }
let!(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
let(:project) { create(:project, :public) }
let(:current_user) { create :admin }
let(:query) do
%(
{
project(fullPath: "#{project.full_path}") {
mergeRequests {
nodes {
divergedFromTargetBranch
}
}
}
}
)
end
it 'delegates the diverged_from_target_branch? call to the merge request entity' do
expect_next_found_instance_of(MergeRequest) do |instance|
expect(instance).to receive(:diverged_from_target_branch?)
end
execute_query
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