From c7c249407e98bf5fc099cd89901e67b000fdf69d Mon Sep 17 00:00:00 2001 From: Grzegorz Bizon Date: Fri, 2 Dec 2016 14:21:04 +0100 Subject: [PATCH] Add implementation of common pipeline extended status --- lib/gitlab/ci/status/core/base.rb | 2 ++ .../ci/status/extended/pipeline/common.rb | 7 +++--- .../status/extended/pipeline/common_spec.rb | 23 +++++++++++++++++++ 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/gitlab/ci/status/core/base.rb b/lib/gitlab/ci/status/core/base.rb index f7687c49ffd..d1896a610b7 100644 --- a/lib/gitlab/ci/status/core/base.rb +++ b/lib/gitlab/ci/status/core/base.rb @@ -4,6 +4,8 @@ module Gitlab::Ci # Base abstract class fore core status # class Base + include Gitlab::Routing.url_helpers + def initialize(subject) @subject = subject end diff --git a/lib/gitlab/ci/status/extended/pipeline/common.rb b/lib/gitlab/ci/status/extended/pipeline/common.rb index 75d392fab6c..1b70ba303dc 100644 --- a/lib/gitlab/ci/status/extended/pipeline/common.rb +++ b/lib/gitlab/ci/status/extended/pipeline/common.rb @@ -3,15 +3,14 @@ module Gitlab::Ci module Extended module Pipeline module Common - def initialize(pipeline) - @pipeline = pipeline - end - def has_details? true end def details_path + namespace_project_pipeline_path(@subject.project.namespace, + @subject.project, + @subject) end def has_action? diff --git a/spec/lib/gitlab/ci/status/extended/pipeline/common_spec.rb b/spec/lib/gitlab/ci/status/extended/pipeline/common_spec.rb index e69de29bb2d..32939800c70 100644 --- a/spec/lib/gitlab/ci/status/extended/pipeline/common_spec.rb +++ b/spec/lib/gitlab/ci/status/extended/pipeline/common_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Extended::Pipeline::Common do + let(:pipeline) { create(:ci_pipeline) } + + subject do + Gitlab::Ci::Status::Core::Success + .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}" + end +end