From 13cee6d7fc568f42a43dd78cc86c033d06faf2b3 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Mon, 5 Dec 2016 14:47:35 +0100 Subject: [PATCH] Fix test failures --- app/models/ci/stage.rb | 6 +++--- lib/gitlab/ci/status/stage/common.rb | 4 ++-- spec/lib/gitlab/ci/status/stage/common_spec.rb | 4 ++-- spec/lib/gitlab/ci/status/stage/factory_spec.rb | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/models/ci/stage.rb b/app/models/ci/stage.rb index d5ff97c935a..fe1c5c642e1 100644 --- a/app/models/ci/stage.rb +++ b/app/models/ci/stage.rb @@ -8,7 +8,7 @@ module Ci delegate :project, to: :pipeline - def initialize(pipeline, name: name, status: nil) + def initialize(pipeline, name:, status: nil) @pipeline, @name, @status = pipeline, name, status end @@ -25,11 +25,11 @@ module Ci end def statuses - @statuses ||= pipeline.statuses.where(stage: stage) + @statuses ||= pipeline.statuses.where(stage: name) end def builds - @builds ||= pipeline.builds.where(stage: stage) + @builds ||= pipeline.builds.where(stage: name) end end end diff --git a/lib/gitlab/ci/status/stage/common.rb b/lib/gitlab/ci/status/stage/common.rb index a1513024c6c..14c437d2b98 100644 --- a/lib/gitlab/ci/status/stage/common.rb +++ b/lib/gitlab/ci/status/stage/common.rb @@ -10,8 +10,8 @@ module Gitlab def details_path namespace_project_pipeline_path(@subject.project.namespace, @subject.project, - @subject, - anchor: subject.name) + @subject.pipeline, + anchor: @subject.name) end def has_action? diff --git a/spec/lib/gitlab/ci/status/stage/common_spec.rb b/spec/lib/gitlab/ci/status/stage/common_spec.rb index c3cb30a35e4..f15d6047878 100644 --- a/spec/lib/gitlab/ci/status/stage/common_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/common_spec.rb @@ -2,11 +2,11 @@ require 'spec_helper' describe Gitlab::Ci::Status::Stage::Common do let(:pipeline) { create(:ci_pipeline) } - let(:stage) { Ci::Stage.new(pipeline, 'test') } + let(:stage) { Ci::Stage.new(pipeline, name: 'test') } subject do Class.new(Gitlab::Ci::Status::Core) - .new(pipeline).extend(described_class) + .new(stage).extend(described_class) end it 'does not have action' do diff --git a/spec/lib/gitlab/ci/status/stage/factory_spec.rb b/spec/lib/gitlab/ci/status/stage/factory_spec.rb index a04fd569fc5..2d22bd1e2a0 100644 --- a/spec/lib/gitlab/ci/status/stage/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/stage/factory_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Gitlab::Ci::Status::Stage::Factory do let(:pipeline) { create(:ci_pipeline) } - let(:stage) { Ci::Stage.new(pipeline, 'test') } + let(:stage) { Ci::Stage.new(pipeline, name: 'test') } subject do described_class.new(stage) @@ -15,7 +15,9 @@ describe Gitlab::Ci::Status::Stage::Factory do 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) } + let!(:build) do + create(:ci_build, pipeline: pipeline, stage: 'test', status: core_status) + end it "fabricates a core status #{core_status}" do expect(status).to be_a(