debian-mirror-gitlab/spec/graphql/resolvers/merge_request_resolver_spec.rb

46 lines
1.5 KiB
Ruby
Raw Normal View History

2018-11-08 19:23:39 +05:30
require 'spec_helper'
2019-05-30 16:15:17 +05:30
describe Resolvers::MergeRequestResolver do
2018-11-08 19:23:39 +05:30
include GraphqlHelpers
set(:project) { create(:project, :repository) }
set(:merge_request_1) { create(:merge_request, :simple, source_project: project, target_project: project) }
set(:merge_request_2) { create(:merge_request, :rebased, source_project: project, target_project: project) }
set(:other_project) { create(:project, :repository) }
set(:other_merge_request) { create(:merge_request, source_project: other_project, target_project: other_project) }
let(:iid_1) { merge_request_1.iid }
let(:iid_2) { merge_request_2.iid }
let(:other_iid) { other_merge_request.iid }
describe '#resolve' do
2019-05-30 16:15:17 +05:30
it 'batch-resolves merge requests by target project full path and IID' do
2018-11-08 19:23:39 +05:30
result = batch(max_queries: 2) do
2019-05-30 16:15:17 +05:30
[resolve_mr(project, iid_1), resolve_mr(project, iid_2)]
2018-11-08 19:23:39 +05:30
end
expect(result).to contain_exactly(merge_request_1, merge_request_2)
end
it 'can batch-resolve merge requests from different projects' do
result = batch(max_queries: 3) do
2019-05-30 16:15:17 +05:30
[resolve_mr(project, iid_1), resolve_mr(project, iid_2), resolve_mr(other_project, other_iid)]
2018-11-08 19:23:39 +05:30
end
expect(result).to contain_exactly(merge_request_1, merge_request_2, other_merge_request)
end
2019-05-30 16:15:17 +05:30
it 'resolves an unknown iid to nil' do
result = batch { resolve_mr(project, -1) }
2018-11-08 19:23:39 +05:30
2019-05-30 16:15:17 +05:30
expect(result).to be_nil
2018-11-08 19:23:39 +05:30
end
end
2019-05-30 16:15:17 +05:30
def resolve_mr(project, iid)
resolve(described_class, obj: project, args: { iid: iid })
2018-11-08 19:23:39 +05:30
end
end