2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Resolvers::MergeRequestPipelinesResolver do
|
2018-11-08 19:23:39 +05:30
|
|
|
include GraphqlHelpers
|
|
|
|
|
2020-04-08 14:13:33 +05:30
|
|
|
let_it_be(:merge_request) { create(:merge_request) }
|
|
|
|
let_it_be(:pipeline) do
|
2018-11-08 19:23:39 +05:30
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: merge_request.source_project,
|
|
|
|
ref: merge_request.source_branch,
|
|
|
|
sha: merge_request.diff_head_sha
|
|
|
|
)
|
|
|
|
end
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
let_it_be(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project, ref: 'other-ref') }
|
2020-04-08 14:13:33 +05:30
|
|
|
let_it_be(:other_pipeline) { create(:ci_pipeline) }
|
2021-06-08 01:23:25 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
merge_request.project.add_developer(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_pipelines
|
2021-02-22 17:27:13 +05:30
|
|
|
sync(resolve(described_class, obj: merge_request, ctx: { current_user: current_user }))
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolves only MRs for the passed merge request' do
|
|
|
|
expect(resolve_pipelines).to contain_exactly(pipeline)
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
describe 'with archived project' do
|
|
|
|
let(:archived_project) { create(:project, :archived) }
|
|
|
|
let(:merge_request) { create(:merge_request, source_project: archived_project) }
|
|
|
|
|
|
|
|
it { expect(resolve_pipelines).not_to contain_exactly(pipeline) }
|
|
|
|
end
|
2018-11-08 19:23:39 +05:30
|
|
|
end
|