Commit 361914a6 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Make :minutes_cost_factor always return a float

parent 490202ec
......@@ -37,7 +37,7 @@ module EE
def shared_runners_minutes_limit_enabled?
if ::Feature.enabled?(:ci_minutes_enforce_quota_for_public_projects)
project.shared_runners_minutes_limit_enabled? && runner&.minutes_cost_factor(project.visibility_level)
project.shared_runners_minutes_limit_enabled? && runner&.minutes_cost_factor(project.visibility_level)&.positive?
else
legacy_shared_runners_minutes_limit_enabled?
end
......
......@@ -10,19 +10,19 @@ module EE
end
def minutes_cost_factor(access_level)
return unless instance_type?
return 0.0 unless instance_type?
case access_level
when ::Gitlab::VisibilityLevel::PUBLIC
public_projects_minutes_cost_factor if public_projects_minutes_cost_factor&.positive?
public_projects_minutes_cost_factor
else # Gitlab::VisibilityLevel::PRIVATE/INTERNAL
private_projects_minutes_cost_factor if private_projects_minutes_cost_factor&.positive?
private_projects_minutes_cost_factor
end
end
def visibility_levels_without_minutes_quota
::Gitlab::VisibilityLevel.options.values.reject do |visibility_level|
minutes_cost_factor(visibility_level)&.positive?
minutes_cost_factor(visibility_level).positive?
end
end
end
......
......@@ -29,7 +29,7 @@ describe EE::Ci::Runner do
context "with #{level_name}" do
let(:visibility_level) {level_value}
it { is_expected.to be_nil }
it { is_expected.to eq(0.0) }
end
end
end
......@@ -41,7 +41,7 @@ describe EE::Ci::Runner do
context "with #{level_name}" do
let(:visibility_level) {level_value}
it { is_expected.to be_nil }
it { is_expected.to eq(0.0) }
end
end
end
......
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