summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-10-28 03:47:49 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-10-28 03:47:49 +0800
commit3e6a527e686e27b3cd9e048a17f1b491023d07d1 (patch)
tree3b02410821d3023435cf799df8aa460d17e8788e
parentf4b9de38edb3152888cb8e9ea0f9e48a6f08dd26 (diff)
downloadgitlab-ce-3e6a527e686e27b3cd9e048a17f1b491023d07d1.tar.gz
Add tests for Commit#status and Commit#status_for, feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7034#note_17543036
-rw-r--r--spec/models/commit_spec.rb45
1 files changed, 44 insertions, 1 deletions
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 51be3f36135..468e198e9ea 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -210,7 +210,50 @@ eos
end
describe '#status' do
- # TODO: kamil
+ shared_examples 'giving the status from pipeline' do
+ it do
+ expect(commit.status).to eq(Ci::Pipeline.status)
+ end
+ end
+
+ context 'with pipelines' do
+ let!(:pipeline) do
+ create(:ci_empty_pipeline, project: project, sha: commit.sha)
+ end
+
+ it_behaves_like 'giving the status from pipeline'
+ end
+
+ context 'without pipelines' do
+ it_behaves_like 'giving the status from pipeline'
+ end
+ end
+
+ describe '#status_for' do
+ let!(:pipeline_from_master) do
+ create(:ci_empty_pipeline,
+ project: project,
+ sha: commit.sha,
+ ref: 'master',
+ status: 'failed')
+ end
+
+ let!(:pipeline_from_fix) do
+ create(:ci_empty_pipeline,
+ project: project,
+ sha: commit.sha,
+ ref: 'fix',
+ status: 'success')
+ end
+
+ it 'gives pipelines from a particular branch' do
+ expect(commit.status_for('master')).to eq(pipeline_from_master.status)
+ expect(commit.status_for('fix')).to eq(pipeline_from_fix.status)
+ end
+
+ it 'gives compound status if ref is nil' do
+ expect(commit.status_for(nil)).to eq(commit.status)
+ end
end
describe '#participants' do