diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 11:00:56 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-20 11:00:56 +0100 |
commit | 2b0b53cddd7d57ca5dd93437fdffefd7a07af91e (patch) | |
tree | e309a1b9fd1dd7ee6fd6552d112f1497a894663b /spec | |
parent | ac86c495a3fc54be6984c4df2b363e9b4e414b4d (diff) | |
download | gitlab-ce-2b0b53cddd7d57ca5dd93437fdffefd7a07af91e.tar.gz |
Add tests for stage API endpoint
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/pipelines/pipelines_spec.rb | 29 | ||||
-rw-r--r-- | spec/models/ci/pipeline_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/ci/stage_spec.rb | 11 |
3 files changed, 60 insertions, 0 deletions
diff --git a/spec/features/projects/pipelines/pipelines_spec.rb b/spec/features/projects/pipelines/pipelines_spec.rb index f3731698a18..e1c6b4c115c 100644 --- a/spec/features/projects/pipelines/pipelines_spec.rb +++ b/spec/features/projects/pipelines/pipelines_spec.rb @@ -152,6 +152,35 @@ describe "Pipelines" do end end + describe 'GET /:project/pipelines/stage?name=stage' do + let!(:pipeline) do + create(:ci_empty_pipeline, project: project, ref: 'master', + status: 'running') + end + + context 'when accessing existing stage' do + let!(:build) do + create(:ci_build, pipeline: pipeline, stage: 'build') + end + + before do + visit stage_namespace_project_pipeline_path( + project.namespace, project, pipeline, format: :json, stage: 'build') + end + + it { expect(page).to have_http_status(:ok) } + end + + context 'when accessing unknown stage' do + before do + visit stage_namespace_project_pipeline_path( + project.namespace, project, pipeline, format: :json, stage: 'test') + end + + it { expect(page).to have_http_status(:not_found) } + end + end + describe 'POST /:project/pipelines' do let(:project) { create(:project) } 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) } |