Remove reduntant method for building pipeline builds

This commit is contained in:
Grzegorz Bizon 2016-06-15 14:03:43 +02:00
parent 69112072ca
commit 2d495fce52
5 changed files with 12 additions and 9 deletions

View file

@ -91,15 +91,14 @@ module Ci
trigger_requests.any?
end
def build_builds(user, trigger_request = nil)
def create_builds(user, trigger_request = nil)
##
# We persist pipeline only if there are builds available
#
return unless config_processor
build_builds_for_stages(config_processor.stages, user,
'success', trigger_request)
end
def create_builds(user, trigger_request = nil)
build_builds(user, trigger_request) && save
'success', trigger_request) && save
end
def create_next_builds(build)
@ -121,7 +120,6 @@ module Ci
# and save pipeline if we have builds
build_builds_for_stages(next_stages, build.user, prior_status,
build.trigger_request) && save
end
def retried

View file

@ -22,7 +22,8 @@ module Ci
# don't create the same build twice
builds_attrs.reject! do |build_attrs|
@pipeline.builds.find_by(ref: @pipeline.ref, tag: @pipeline.tag,
@pipeline.builds.find_by(ref: @pipeline.ref,
tag: @pipeline.tag,
trigger_request: trigger_request,
name: build_attrs[:name])
end

View file

@ -42,7 +42,7 @@ class CreateCommitBuildsService
##
# Skip creating pipeline object if there are no builds for it.
#
unless @pipeline.build_builds(user)
unless @pipeline.create_builds(user)
@pipeline.errors.add(:base, 'No builds created')
return false
end

View file

@ -260,12 +260,15 @@ describe Ci::Pipeline, models: true do
end
context 'when no builds created' do
let(:pipeline) { build(:ci_pipeline) }
before do
stub_ci_pipeline_yaml_file(YAML.dump(before_script: ['ls']))
end
it 'returns false' do
expect(pipeline.create_builds(nil)).to be_falsey
expect(pipeline).not_to be_persisted
end
end
end

View file

@ -184,6 +184,7 @@ describe CreateCommitBuildsService, services: true do
before: '00000000',
after: '31das312',
commits: [{ message: 'some msg' }])
expect(result).to be_falsey
expect(Ci::Build.all).to be_empty
expect(Ci::Pipeline.count).to eq(0)