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