Commit c9d305d3 authored by Avielle Wolfe's avatar Avielle Wolfe

Rename method to `#cost_factor_enabled?`

As suggested in https://gitlab.com/gitlab-org/gitlab/-/issues/336021,
`#cost_factor_enabled?` is a more accurate name for
`Ci::Build#shared_runners_minutes_limit_enabled?`
parent 271267ed
......@@ -67,7 +67,7 @@ module EE
end
end
def shared_runners_minutes_limit_enabled?
def cost_factor_enabled?
runner&.cost_factor_enabled?(project)
end
......
......@@ -77,8 +77,8 @@ module Ci
ServiceResponse.error(message: 'Feature not enabled')
elsif !build.running?
ServiceResponse.error(message: 'Build is not running')
elsif !build.shared_runners_minutes_limit_enabled?
ServiceResponse.error(message: 'CI minutes limit not enabled for build')
elsif !build.cost_factor_enabled?
ServiceResponse.error(message: 'Cost factor not enabled for build')
else
ServiceResponse.success
end
......
......@@ -6,7 +6,7 @@ module Ci
# Calculates consumption and updates the project and namespace statistics(legacy)
# or ProjectMonthlyUsage and NamespaceMonthlyUsage(not legacy) based on the passed build.
def execute(build)
return unless build.shared_runners_minutes_limit_enabled?
return unless build.cost_factor_enabled?
return unless build.complete?
return unless build.duration&.positive?
......
......@@ -48,8 +48,8 @@ RSpec.describe Ci::Build do
it { is_expected.to have_one(:dast_scanner_profile).class_name('DastScannerProfile').through(:dast_scanner_profiles_build) }
end
describe '#shared_runners_minutes_limit_enabled?' do
subject { job.shared_runners_minutes_limit_enabled? }
describe '#cost_factor_enabled?' do
subject { job.cost_factor_enabled? }
context 'for shared runner' do
before do
......
......@@ -69,15 +69,15 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
context 'when runner is not of instance type' do
let(:runner) { create(:ci_runner, :project) }
it_behaves_like 'returns early', 'CI minutes limit not enabled for build'
it_behaves_like 'returns early', 'Cost factor not enabled for build'
end
context 'when shared runners limit is not enabled for build' do
context 'when cost factor is not enabled for build' do
before do
allow(build).to receive(:shared_runners_minutes_limit_enabled?).and_return(false)
allow(build).to receive(:cost_factor_enabled?).and_return(false)
end
it_behaves_like 'returns early', 'CI minutes limit not enabled for build'
it_behaves_like 'returns early', 'Cost factor not enabled for build'
end
context 'when build has not been tracked recently' do
......
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