diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-07-18 21:11:53 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-07-18 21:11:53 +0800 |
commit | af86b8c2c2b6fb08ea55eb89f1dd20aba81862ae (patch) | |
tree | bd601a53c7de7e2b43e67b71cbb8054ce31230c8 /spec/models | |
parent | 85409a5a10d22bebbc54a9c7b7c76e7c0e11b208 (diff) | |
download | gitlab-ce-af86b8c2c2b6fb08ea55eb89f1dd20aba81862ae.tar.gz |
Latest success pipelines (rather than builds)
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/build_spec.rb | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/spec/models/build_spec.rb b/spec/models/build_spec.rb index 53064138a50..8a8a4b46f08 100644 --- a/spec/models/build_spec.rb +++ b/spec/models/build_spec.rb @@ -6,7 +6,8 @@ describe Ci::Build, models: true do let(:pipeline) do create(:ci_pipeline, project: project, sha: project.commit.id, - ref: 'fix') + ref: 'fix', + status: 'success') end let(:build) { create(:ci_build, pipeline: pipeline) } @@ -694,20 +695,38 @@ describe Ci::Build, models: true do end describe 'Project#latest_success_builds_for' do + let(:build) do + create(:ci_build, :artifacts, :success, pipeline: pipeline) + end + before do - build.update(status: 'success') + build end - it 'returns builds from ref' do - builds = project.latest_success_builds_for('fix') + context 'with succeed pipeline' do + it 'returns builds from ref' do + builds = project.latest_success_builds_for('fix') + + expect(builds).to contain_exactly(build) + end + + it 'returns empty relation if the build cannot be found' do + builds = project.latest_success_builds_for('TAIL').all - expect(builds).to contain_exactly(build) + expect(builds).to be_empty + end end - it 'returns empty relation if the build cannot be found' do - builds = project.latest_success_builds_for('TAIL').all + context 'with pending pipeline' do + before do + pipeline.update(status: 'pending') + end - expect(builds).to be_empty + it 'returns empty relation' do + builds = project.latest_success_builds_for('fix').all + + expect(builds).to be_empty + end end end end |