diff options
author | Tomasz Maczukin <tomasz@maczukin.pl> | 2016-08-29 14:10:14 +0200 |
---|---|---|
committer | Tomasz Maczukin <tomasz@maczukin.pl> | 2016-09-01 14:00:46 +0200 |
commit | e2e8ec6074a4b7552188b169cfe9c4612b740428 (patch) | |
tree | 468dcbe96b638de1bd6c1312f7255e9daf5a2fc1 | |
parent | 77295de4076835d6080a9868fe7cb0c08522e141 (diff) | |
download | gitlab-ce-e2e8ec6074a4b7552188b169cfe9c4612b740428.tar.gz |
Add specs
-rw-r--r-- | spec/models/ci/build_spec.rb | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 36d10636ae9..1dd26750edd 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -19,4 +19,55 @@ describe Ci::Build, models: true do expect(build.trace).to eq(test_trace) end end + + describe '#has_trace_file?' do + context 'when there is no trace' do + it { expect(build.has_trace_file?).to be_falsey } + it { expect(build.trace).to be_nil } + end + + context 'when there is a trace' do + context 'when trace is stored in file' do + before do + build.trace = test_trace + build.save + end + + it { expect(build.has_trace_file?).to be_truthy } + it { expect(build.trace).to eq(test_trace) } + end + + context 'when trace is stored in old file' do + before do + build.trace = test_trace + build.save + + build.project.ci_id = 999 + build.project.save + + FileUtils.mkdir_p(build.old_dir_to_trace) + FileUtils.mv(build.path_to_trace, build.old_path_to_trace) + end + + it { expect(build.has_trace_file?).to be_truthy } + it { expect(build.trace).to eq(test_trace) } + end + + context 'when there is stored in DB' do + class Ci::Build + def write_db_trace=(trace) + write_attribute :trace, trace + end + end + + before do + build.write_db_trace = test_trace + build.save + end + + it { expect(build.has_trace_file?).to be_falsey } + it { expect(build.trace).to eq(test_trace) } + end + end + end end |