summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-01-09 13:07:52 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-01-11 13:53:17 +0100
commitfd115bc130a8bf77814262b67eb0f20f1f19cb85 (patch)
treee13d684351d4eda357b9a768257941b3e46ad0a4
parent8dbd1e7d0000bb08b6ac6867530bb501eadc85a4 (diff)
downloadgitlab-ce-fd115bc130a8bf77814262b67eb0f20f1f19cb85.tar.gz
Add specs for two new methods defined in stage class
-rw-r--r--spec/lib/gitlab/ci/status/stage/factory_spec.rb1
-rw-r--r--spec/models/ci/stage_spec.rb48
2 files changed, 48 insertions, 1 deletions
diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb
index a60f84be9e9..bbb40e2c1ab 100644
--- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb
@@ -42,7 +42,6 @@ describe Gitlab::Ci::Status::Stage::Factory do
end
end
end
-
end
context 'when stage has warnings' do
diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb
index 742bedb37e4..3d387d52c8e 100644
--- a/spec/models/ci/stage_spec.rb
+++ b/spec/models/ci/stage_spec.rb
@@ -142,6 +142,54 @@ describe Ci::Stage, models: true do
end
end
+ describe '#success?' do
+ context 'when stage is successful' do
+ before do
+ create_job(:ci_build, status: :success)
+ create_job(:generic_commit_status, status: :success)
+ end
+
+ it 'is successful' do
+ expect(stage).to be_success
+ end
+ end
+
+ context 'when stage is not successful' do
+ before do
+ create_job(:ci_build, status: :failed)
+ create_job(:generic_commit_status, status: :success)
+ end
+
+ it 'is not successful' do
+ expect(stage).not_to be_success
+ end
+ end
+ end
+
+ describe '#has_warnings?' do
+ context 'when stage has warnings' do
+ before do
+ create(:ci_build, :failed, :allowed_to_fail,
+ stage: stage_name, pipeline: pipeline)
+ end
+
+ it 'has warnings' do
+ expect(stage).to have_warnings
+ end
+ end
+
+ context 'when stage does not have warnings' do
+ before do
+ create(:ci_build, :success, stage: stage_name,
+ pipeline: pipeline)
+ end
+
+ it 'does not have warnings' do
+ expect(stage).not_to have_warnings
+ end
+ end
+ end
+
def create_job(type, status: 'success', stage: stage_name)
create(type, pipeline: pipeline, stage: stage, status: status)
end