Commit 2ed251e7 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'fix-ci-composite-status-ci-group' into 'master'

Fix missing scope for `ci_composite_status`

See merge request gitlab-org/gitlab!29129
parents 80987803 60a865d0
...@@ -11,11 +11,12 @@ module Ci ...@@ -11,11 +11,12 @@ module Ci
include StaticModel include StaticModel
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
attr_reader :stage, :name, :jobs attr_reader :project, :stage, :name, :jobs
delegate :size, to: :jobs delegate :size, to: :jobs
def initialize(stage, name:, jobs:) def initialize(project, stage, name:, jobs:)
@project = project
@stage = stage @stage = stage
@name = name @name = name
@jobs = jobs @jobs = jobs
...@@ -23,7 +24,7 @@ module Ci ...@@ -23,7 +24,7 @@ module Ci
def status def status
strong_memoize(:status) do strong_memoize(:status) do
if Feature.enabled?(:ci_composite_status, default_enabled: false) if Feature.enabled?(:ci_composite_status, project, default_enabled: false)
Gitlab::Ci::Status::Composite Gitlab::Ci::Status::Composite
.new(@jobs) .new(@jobs)
.status .status
...@@ -44,11 +45,11 @@ module Ci ...@@ -44,11 +45,11 @@ module Ci
end end
end end
def self.fabricate(stage) def self.fabricate(project, stage)
stage.statuses.ordered.latest stage.statuses.ordered.latest
.sort_by(&:sortable_name).group_by(&:group_name) .sort_by(&:sortable_name).group_by(&:group_name)
.map do |group_name, grouped_statuses| .map do |group_name, grouped_statuses|
self.new(stage, name: group_name, jobs: grouped_statuses) self.new(project, stage, name: group_name, jobs: grouped_statuses)
end end
end end
end end
......
...@@ -20,7 +20,7 @@ module Ci ...@@ -20,7 +20,7 @@ module Ci
end end
def groups def groups
@groups ||= Ci::Group.fabricate(self) @groups ||= Ci::Group.fabricate(project, self)
end end
def to_param def to_param
......
...@@ -109,7 +109,7 @@ module Ci ...@@ -109,7 +109,7 @@ module Ci
end end
def groups def groups
@groups ||= Ci::Group.fabricate(self) @groups ||= Ci::Group.fabricate(project, self)
end end
def has_warnings? def has_warnings?
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
require 'spec_helper' require 'spec_helper'
describe Ci::Group do describe Ci::Group do
let_it_be(:project) { create(:project) }
let!(:jobs) { build_list(:ci_build, 1, :success, project: project) }
subject do subject do
described_class.new('test', name: 'rspec', jobs: jobs) described_class.new(project, 'test', name: 'rspec', jobs: jobs)
end end
let!(:jobs) { build_list(:ci_build, 1, :success) }
it { is_expected.to include_module(StaticModel) } it { is_expected.to include_module(StaticModel) }
it { is_expected.to respond_to(:stage) } it { is_expected.to respond_to(:stage) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment