diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb index e2ce5062f6f5a5570cca05b783ce55d2b3ab4f14..4a064644d64e1d29c04673cc50b25b7deb615e11 100644 --- a/app/models/commit_status.rb +++ b/app/models/commit_status.rb @@ -65,8 +65,8 @@ class CommitStatus < ActiveRecord::Base end event :cancel do - transition [:pending, :running] => :canceled transition [:created] => :skipped + transition [:pending, :running] => :canceled end before_transition created: [:pending, :running] do |commit_status| diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 426be74cd0209865a2f6ee1541bf580e39bb30c4..3be489c7c5c812abf2af52355eddcdd6fbb27378 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -503,7 +503,9 @@ describe Ci::Pipeline, models: true do end describe '#status' do - let!(:build) { create(:ci_build, :created, pipeline: pipeline, name: 'test') } + let(:build) do + create(:ci_build, :created, pipeline: pipeline, name: 'test') + end subject { pipeline.reload.status } @@ -545,7 +547,13 @@ describe Ci::Pipeline, models: true do build.cancel end - it { is_expected.to eq('canceled') } + context 'when build is pending' do + let(:build) do + create(:ci_build, :pending, pipeline: pipeline) + end + + it { is_expected.to eq('canceled') } + end end context 'on failure and build retry' do