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
include StaticModel
include Gitlab::Utils::StrongMemoize
attr_reader :stage, :name, :jobs
attr_reader :project, :stage, :name, :jobs
delegate :size, to: :jobs
def initialize(stage, name:, jobs:)
def initialize(project, stage, name:, jobs:)
@project = project
@stage = stage
@name = name
@jobs = jobs
......@@ -23,7 +24,7 @@ module Ci
def status
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
.new(@jobs)
.status
......@@ -44,11 +45,11 @@ module Ci
end
end
def self.fabricate(stage)
def self.fabricate(project, stage)
stage.statuses.ordered.latest
.sort_by(&:sortable_name).group_by(&:group_name)
.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
......
......@@ -20,7 +20,7 @@ module Ci
end
def groups
@groups ||= Ci::Group.fabricate(self)
@groups ||= Ci::Group.fabricate(project, self)
end
def to_param
......
......@@ -109,7 +109,7 @@ module Ci
end
def groups
@groups ||= Ci::Group.fabricate(self)
@groups ||= Ci::Group.fabricate(project, self)
end
def has_warnings?
......
......@@ -3,12 +3,14 @@
require 'spec_helper'
describe Ci::Group do
let_it_be(:project) { create(:project) }
let!(:jobs) { build_list(:ci_build, 1, :success, project: project) }
subject do
described_class.new('test', name: 'rspec', jobs: jobs)
described_class.new(project, 'test', name: 'rspec', jobs: jobs)
end
let!(:jobs) { build_list(:ci_build, 1, :success) }
it { is_expected.to include_module(StaticModel) }
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