2019-10-17 05:07:07 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-06-26 12:31:05 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Resolvers::MergeRequestPipelinesResolver do
|
2018-06-26 12:31:05 -04:00
|
|
|
include GraphqlHelpers
|
|
|
|
|
2020-02-18 10:08:51 -05:00
|
|
|
let_it_be(:merge_request) { create(:merge_request) }
|
|
|
|
let_it_be(:pipeline) do
|
2018-06-26 12:31:05 -04:00
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: merge_request.source_project,
|
|
|
|
ref: merge_request.source_branch,
|
|
|
|
sha: merge_request.diff_head_sha
|
|
|
|
)
|
|
|
|
end
|
2020-11-17 10:09:28 -05:00
|
|
|
|
2020-04-13 23:09:39 -04:00
|
|
|
let_it_be(:other_project_pipeline) { create(:ci_pipeline, project: merge_request.source_project, ref: 'other-ref') }
|
2020-02-18 10:08:51 -05:00
|
|
|
let_it_be(:other_pipeline) { create(:ci_pipeline) }
|
2021-04-21 17:09:40 -04:00
|
|
|
|
2018-06-26 12:31:05 -04:00
|
|
|
let(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
merge_request.project.add_developer(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_pipelines
|
2020-12-09 13:09:48 -05:00
|
|
|
sync(resolve(described_class, obj: merge_request, ctx: { current_user: current_user }))
|
2018-06-26 12:31:05 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolves only MRs for the passed merge request' do
|
|
|
|
expect(resolve_pipelines).to contain_exactly(pipeline)
|
|
|
|
end
|
2020-09-11 20:08:44 -04:00
|
|
|
|
|
|
|
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-06-26 12:31:05 -04:00
|
|
|
end
|