debian-mirror-gitlab/spec/services/ci/process_pipeline_service_spec.rb

48 lines
1.1 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
require 'spec_helper'
2020-03-09 13:42:32 +05:30
describe Ci::ProcessPipelineService do
2016-09-13 17:45:13 +05:30
let(:user) { create(:user) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2017-08-17 22:00:37 +05:30
let(:pipeline) do
create(:ci_empty_pipeline, ref: 'master', project: project)
end
2016-09-13 17:45:13 +05:30
before do
2018-05-09 12:01:36 +05:30
stub_ci_pipeline_to_return_yaml_file
2017-09-10 17:25:29 +05:30
stub_not_protect_default_branch
2017-08-17 22:00:37 +05:30
project.add_developer(user)
2016-09-13 17:45:13 +05:30
end
2017-08-17 22:00:37 +05:30
context 'updates a list of retried builds' do
subject { described_class.retried.order(:id) }
let!(:build_retried) { create_build('build') }
let!(:build) { create_build('build') }
let!(:test) { create_build('test') }
it 'returns unique statuses' do
process_pipeline
expect(all_builds.latest).to contain_exactly(build, test)
expect(all_builds.retried).to contain_exactly(build_retried)
end
end
def process_pipeline
2020-01-01 13:55:28 +05:30
described_class.new(pipeline).execute
2017-08-17 22:00:37 +05:30
end
def create_build(name, **opts)
create(:ci_build, :created, pipeline: pipeline, name: name, **opts)
end
2018-12-05 23:21:45 +05:30
2020-03-09 13:42:32 +05:30
def all_builds
pipeline.builds.order(:stage_idx, :id)
2018-12-05 23:21:45 +05:30
end
2016-09-13 17:45:13 +05:30
end