summaryrefslogtreecommitdiff
path: root/spec/models/ci
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-12-06 16:40:56 +0900
committerShinya Maeda <shinya@gitlab.com>2017-12-06 16:40:56 +0900
commitcd23850e0002f6c39b0c7f97c1dc484d7993af04 (patch)
tree49f6467e53bddc199afc963c86ae2edcc6c4fe3d /spec/models/ci
parent6171db2d2df337ef52460387a48f28136e809861 (diff)
downloadgitlab-ce-cd23850e0002f6c39b0c7f97c1dc484d7993af04.tar.gz
Fix tests
Diffstat (limited to 'spec/models/ci')
-rw-r--r--spec/models/ci/build_spec.rb44
1 files changed, 27 insertions, 17 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb
index 2cacf04a791..96d9fba2a2d 100644
--- a/spec/models/ci/build_spec.rb
+++ b/spec/models/ci/build_spec.rb
@@ -1891,11 +1891,7 @@ describe Ci::Build do
let(:options) { { dependencies: ['test'] } }
context 'when a depended job exists' do
- let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
-
- it { expect { build.run! }.not_to raise_error }
-
- context 'when "artifacts" keyword is specified on depended job' do
+ context 'when depended job has artifacts' do
let!(:pre_stage_job) do
create(:ci_build,
:success,
@@ -1906,22 +1902,36 @@ describe Ci::Build do
options: { artifacts: { paths: ['binaries/'] } } )
end
- context 'when artifacts of depended job has existsed' do
- it { expect { build.run! }.not_to raise_error }
- end
+ it { expect { build.run! }.not_to raise_error }
+ end
- context 'when artifacts of depended job has not existsed' do
- before do
- pre_stage_job.erase_artifacts!
- end
+ context 'when depended job does not have artifacts' do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
- it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
- end
+ it { expect { build.run! }.not_to raise_error }
end
- end
- context 'when depended jobs do not exist' do
- it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
+ context 'when depended job has not been completed yet' do
+ let!(:pre_stage_job) { create(:ci_build, :running, pipeline: pipeline, name: 'test', stage_idx: 0) }
+
+ it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
+ end
+
+ context 'when artifacts of depended job has been expired' do
+ let!(:pre_stage_job) { create(:ci_build, :success, :expired, pipeline: pipeline, name: 'test', stage_idx: 0) }
+
+ it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
+ end
+
+ context 'when artifacts of depended job has been erased' do
+ let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0, erased_at: 1.minute.ago) }
+
+ before do
+ pre_stage_job.erase
+ end
+
+ it { expect { build.run! }.to raise_error(Ci::Build::MissingDependenciesError) }
+ end
end
end
end