diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 13:00:56 +0300 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 13:00:56 +0300 |
commit | 2b0b53cddd7d57ca5dd93437fdffefd7a07af91e (patch) | |
tree | e309a1b9fd1dd7ee6fd6552d112f1497a894663b /spec/models/ci | |
parent | ac86c495a3fc54be6984c4df2b363e9b4e414b4d (diff) |
Add tests for stage API endpoint
Diffstat (limited to 'spec/models/ci')
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/ci/stage_spec.rb | 11 |
2 files changed, 31 insertions, 0 deletions
diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 52dd41065e9..67cc3e6be68 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -175,6 +175,26 @@ describe Ci::Pipeline, models: true do end end + describe '#stage' do + subject { pipeline.stage('test') } + + context 'with status in stage' do + let!(:status) { create(:commit_status, pipeline: pipeline, stage: 'test') } + + it 'return stage object' do + is_expected.to be_a(Ci::Stage) + end + end + + context 'without status in stage' do + let!(:status) { create(:commit_status, pipeline: pipeline, stage: 'build') } + + it 'return stage object' do + is_expected.to be_nil + end + end + end + describe 'state machine' do let(:current) { Time.now.change(usec: 0) } let(:build) { create_build('build1', 0) } diff --git a/spec/models/ci/stage_spec.rb b/spec/models/ci/stage_spec.rb index 8fff38f7cda..d8dce0f1cc6 100644 --- a/spec/models/ci/stage_spec.rb +++ b/spec/models/ci/stage_spec.rb @@ -28,6 +28,17 @@ describe Ci::Stage, models: true do end end + describe '#statuses_count' do + let!(:stage_build) { create_job(:ci_build) } + let!(:other_build) { create_job(:ci_build, stage: 'other stage') } + + subject { stage.statuses_count } + + it "statuses only from current stage" do + is_expected.to eq(1) + end + end + describe '#builds' do let!(:stage_build) { create_job(:ci_build) } let!(:commit_status) { create_job(:commit_status) } |