diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-05 14:38:01 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2016-12-06 14:13:21 +0100 |
commit | 10499677e2cbabc6331837d20afc0e0fe68ddc37 (patch) | |
tree | 88439ea52ae889f4bb97478c20b3f54799abd7aa /spec | |
parent | d47aef58cd88fb813390c904bd24525e24d41483 (diff) | |
download | gitlab-ce-10499677e2cbabc6331837d20afc0e0fe68ddc37.tar.gz |
Added Stage tests
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/ci/status/stage/common_spec.rb | 26 | ||||
-rw-r--r-- | spec/lib/gitlab/ci/status/stage/factory_spec.rb | 33 |
2 files changed, 59 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/status/stage/common_spec.rb b/spec/lib/gitlab/ci/status/stage/common_spec.rb new file mode 100644 index 00000000000..c3cb30a35e4 --- /dev/null +++ b/spec/lib/gitlab/ci/status/stage/common_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Stage::Common do + let(:pipeline) { create(:ci_pipeline) } + let(:stage) { Ci::Stage.new(pipeline, 'test') } + + subject do + Class.new(Gitlab::Ci::Status::Core) + .new(pipeline).extend(described_class) + end + + it 'does not have action' do + expect(subject).not_to have_action + end + + it 'has details' do + expect(subject).to have_details + end + + it 'links to the pipeline details page' do + expect(subject.details_path) + .to include "pipelines/#{pipeline.id}" + expect(subject.details_path) + .to include "##{stage.name}" + end +end diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb new file mode 100644 index 00000000000..a04fd569fc5 --- /dev/null +++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Stage::Factory do + let(:pipeline) { create(:ci_pipeline) } + let(:stage) { Ci::Stage.new(pipeline, 'test') } + + subject do + described_class.new(stage) + end + + let(:status) do + subject.fabricate! + end + + context 'when stage has a core status' do + HasStatus::AVAILABLE_STATUSES.each do |core_status| + context "when core status is #{core_status}" do + let(:build) { create(:ci_build, pipeline: pipeline, stage: stage.name, status: core_status) } + + it "fabricates a core status #{core_status}" do + expect(status).to be_a( + Gitlab::Ci::Status.const_get(core_status.capitalize)) + end + + it 'extends core status with common pipeline methods' do + expect(status).to have_details + expect(status.details_path).to include "pipelines/#{pipeline.id}" + expect(status.details_path).to include "##{stage.name}" + end + end + end + end +end |