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 | |
| parent | d47aef58cd88fb813390c904bd24525e24d41483 (diff) | |
| download | gitlab-ce-10499677e2cbabc6331837d20afc0e0fe68ddc37.tar.gz | |
Added Stage tests
| -rw-r--r-- | app/models/ci/stage.rb | 4 | ||||
| -rw-r--r-- | lib/gitlab/ci/status/stage/factory.rb | 2 | ||||
| -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 |
4 files changed, 64 insertions, 1 deletions
diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index 2e7f15a16d7..d5ff97c935a 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -20,6 +20,10 @@ module Ci @status ||= statuses.latest.status end + def detailed_status + Gitlab::Ci::Status::Stage::Factory.new(self).fabricate! + end + def statuses @statuses ||= pipeline.statuses.where(stage: stage) end diff --git a/lib/gitlab/ci/status/stage/factory.rb b/lib/gitlab/ci/status/stage/factory.rb index 2e485ee22a9..a2f7ad81d39 100644 --- a/lib/gitlab/ci/status/stage/factory.rb +++ b/lib/gitlab/ci/status/stage/factory.rb @@ -24,7 +24,7 @@ module Gitlab Gitlab::Ci::Status .const_get(@status.capitalize) .new(@stage) - .extend(Status::Pipeline::Common) + .extend(Status::Stage::Common) end def extended_status 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 |
