2019-12-26 22:10:19 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Resolvers::CommitPipelinesResolver do
|
2019-12-26 22:10:19 +05:30
|
|
|
include GraphqlHelpers
|
|
|
|
|
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let(:commit) { create(:commit, project: project) }
|
|
|
|
let_it_be(:current_user) { create(:user) }
|
|
|
|
|
|
|
|
let!(:pipeline) do
|
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: project,
|
|
|
|
sha: commit.id,
|
|
|
|
ref: 'master',
|
|
|
|
status: 'success'
|
|
|
|
)
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
let!(:pipeline2) do
|
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: project,
|
|
|
|
sha: commit.id,
|
|
|
|
ref: 'master',
|
|
|
|
status: 'failed'
|
|
|
|
)
|
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
let!(:pipeline3) do
|
|
|
|
create(
|
|
|
|
:ci_pipeline,
|
|
|
|
project: project,
|
|
|
|
sha: commit.id,
|
|
|
|
ref: 'my_branch',
|
|
|
|
status: 'failed'
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
commit.project.add_developer(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resolve_pipelines
|
|
|
|
resolve(described_class, obj: commit, ctx: { current_user: current_user }, args: { ref: 'master' })
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resolves pipelines for commit and ref' do
|
|
|
|
pipelines = resolve_pipelines
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
expect(pipelines.to_a).to eq([pipeline2, pipeline])
|
2019-12-26 22:10:19 +05:30
|
|
|
end
|
|
|
|
end
|