summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-09 11:11:42 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-02-13 15:11:21 +0100
commit008f22cd820a5bf9e8ff9a68550c9550463d3279 (patch)
tree20b1ee59cfeebf37e507fe4aa870d7b3c25e5206
parenta70a83cf290d12ec83b79e35fd5e92375216fc43 (diff)
downloadgitlab-ce-008f22cd820a5bf9e8ff9a68550c9550463d3279.tar.gz
Fix pipeline specs related to canceling builds
-rw-r--r--app/models/commit_status.rb2
-rw-r--r--spec/models/ci/pipeline_spec.rb12
2 files changed, 11 insertions, 3 deletions
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index e2ce5062f6f..4a064644d64 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 426be74cd02..3be489c7c5c 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