2019-10-17 09:07:07 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-25 08:59:00 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 09:08:32 +00:00
|
|
|
RSpec.describe GitlabSchema.types['MergeRequest'] do
|
2020-05-07 06:09:38 +00:00
|
|
|
specify { expect(described_class).to expose_permissions_using(Types::PermissionTypes::MergeRequest) }
|
2018-06-26 16:31:05 +00:00
|
|
|
|
2020-05-07 06:09:38 +00:00
|
|
|
specify { expect(described_class).to require_graphql_authorizations(:read_merge_request) }
|
2018-06-26 16:31:05 +00:00
|
|
|
|
2020-05-07 06:09:38 +00:00
|
|
|
specify { expect(described_class.interfaces).to include(Types::Notes::NoteableType) }
|
2019-06-07 17:13:26 +00:00
|
|
|
|
2020-09-09 21:08:33 +00:00
|
|
|
specify { expect(described_class.interfaces).to include(Types::CurrentUserTodos) }
|
|
|
|
|
2019-06-20 08:02:33 +00:00
|
|
|
it 'has the expected fields' do
|
|
|
|
expected_fields = %w[
|
|
|
|
notes discussions user_permissions id iid title title_html description
|
|
|
|
description_html state created_at updated_at source_project target_project
|
|
|
|
project project_id source_project_id target_project_id source_branch
|
|
|
|
target_branch work_in_progress merge_when_pipeline_succeeds diff_head_sha
|
2020-11-04 18:08:42 +00:00
|
|
|
merge_commit_sha user_notes_count user_discussions_count should_remove_source_branch
|
2020-06-25 06:08:50 +00:00
|
|
|
diff_refs diff_stats diff_stats_summary
|
2019-06-20 08:02:33 +00:00
|
|
|
force_remove_source_branch merge_status in_progress_merge_commit_sha
|
|
|
|
merge_error allow_collaboration should_be_rebased rebase_commit_sha
|
2020-11-18 03:09:21 +00:00
|
|
|
rebase_in_progress default_merge_commit_message
|
2020-05-22 00:08:07 +00:00
|
|
|
merge_ongoing mergeable_discussions_state web_url
|
|
|
|
source_branch_exists target_branch_exists
|
2019-10-17 21:06:41 +00:00
|
|
|
upvotes downvotes head_pipeline pipelines task_completion_status
|
2020-12-21 15:10:05 +00:00
|
|
|
milestone assignees reviewers participants subscribed labels discussion_locked time_estimate
|
2020-09-09 21:08:33 +00:00
|
|
|
total_time_spent reference author merged_at commit_count current_user_todos
|
2020-11-24 18:09:14 +00:00
|
|
|
conflicts auto_merge_enabled approved_by source_branch_protected
|
2020-12-09 18:09:48 +00:00
|
|
|
default_merge_commit_message_with_description squash_on_merge available_auto_merge_strategies
|
2021-01-04 18:10:11 +00:00
|
|
|
has_ci mergeable commits_without_merge_commits squash security_auto_fix default_squash_commit_message
|
2021-01-12 12:10:49 +00:00
|
|
|
auto_merge_strategy merge_user
|
2019-06-20 08:02:33 +00:00
|
|
|
]
|
|
|
|
|
2021-01-12 06:10:31 +00:00
|
|
|
expect(described_class).to have_graphql_fields(*expected_fields).at_least
|
2018-06-26 16:31:05 +00:00
|
|
|
end
|
2020-10-13 18:08:58 +00:00
|
|
|
|
2020-12-09 18:09:48 +00:00
|
|
|
describe '#pipelines' do
|
|
|
|
subject { described_class.fields['pipelines'] }
|
|
|
|
|
|
|
|
it { is_expected.to have_attributes(max_page_size: 500) }
|
|
|
|
end
|
|
|
|
|
2020-10-13 18:08:58 +00:00
|
|
|
describe '#diff_stats_summary' do
|
|
|
|
subject { GitlabSchema.execute(query, context: { current_user: current_user }).as_json }
|
|
|
|
|
|
|
|
let(:current_user) { create :admin }
|
|
|
|
let(:query) do
|
|
|
|
%(
|
|
|
|
{
|
|
|
|
project(fullPath: "#{project.full_path}") {
|
|
|
|
mergeRequests {
|
|
|
|
nodes {
|
|
|
|
diffStatsSummary {
|
|
|
|
additions, deletions
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:project) { create(:project, :public) }
|
|
|
|
let(:merge_request) { create(:merge_request, target_project: project, source_project: project) }
|
|
|
|
|
|
|
|
let(:response) { subject.dig('data', 'project', 'mergeRequests', 'nodes').first['diffStatsSummary'] }
|
|
|
|
|
|
|
|
context 'when MR metrics has additions and deletions' do
|
|
|
|
before do
|
|
|
|
merge_request.metrics.update!(added_lines: 5, removed_lines: 8)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'pulls out data from metrics object' do
|
|
|
|
expect(response).to match('additions' => 5, 'deletions' => 8)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-06-25 08:59:00 +00:00
|
|
|
end
|