diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-05 15:59:31 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2015-10-05 15:59:31 +0200 |
commit | c9853897229ca5585c69c4675cbeefd9ca53147d (patch) | |
tree | 3e0080a4636d751a141d8b01fc891054aca5a47c /spec | |
parent | fb12b81b422e0d17751f4b63462baa503996cd37 (diff) | |
download | gitlab-ce-c9853897229ca5585c69c4675cbeefd9ca53147d.tar.gz |
Add stage tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/ci/commit_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/models/ci/commit_spec.rb b/spec/models/ci/commit_spec.rb index 91cf96a6666..acff1ddf0fc 100644 --- a/spec/models/ci/commit_spec.rb +++ b/spec/models/ci/commit_spec.rb @@ -74,6 +74,40 @@ describe Ci::Commit do it { expect(commit.sha).to start_with(subject) } end + describe :stage do + subject { commit.stage } + + before do + @second = FactoryGirl.create :ci_build, commit: commit, name: 'deploy', stage: 'deploy', stage_idx: 1, status: :pending + @first = FactoryGirl.create :ci_build, commit: commit, name: 'test', stage: 'test', stage_idx: 0, status: :pending + end + + it 'returns first running stage' do + is_expected.to eq('test') + end + + context 'first build succeeded' do + before do + @first.update_attributes(status: :success) + end + + it 'returns last running stage' do + is_expected.to eq('deploy') + end + end + + context 'all builds succeeded' do + before do + @first.update_attributes(status: :success) + @second.update_attributes(status: :success) + end + + it 'returns nil' do + is_expected.to be_nil + end + end + end + describe :create_next_builds do end |