Commit acc18358 authored by Marius Bobin's avatar Marius Bobin

Enable live consumption for all paid plans

Changelog: changed
parent bff3a296
......@@ -77,8 +77,6 @@ module Ci
ServiceResponse.error(message: 'Feature not enabled')
elsif !build.running?
ServiceResponse.error(message: 'Build is not running')
elsif !free_or_trial_plan?
ServiceResponse.error(message: 'Project is not on Free or trial plan')
elsif !build.shared_runners_minutes_limit_enabled?
ServiceResponse.error(message: 'CI minutes limit not enabled for build')
else
......@@ -90,10 +88,6 @@ module Ci
Feature.enabled?(:ci_minutes_track_live_consumption, build.project, default_enabled: :yaml)
end
def free_or_trial_plan?
Gitlab.com? && (root_namespace.free_plan? || root_namespace.trial?)
end
def consumption_since_last_update
last_tracking = time_last_tracked_consumption!(Time.current.utc)
duration = Time.current.utc - last_tracking
......
......@@ -11,10 +11,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
let(:service) { described_class.new(build) }
before do
allow(Gitlab).to receive(:com?).and_return(true)
end
describe '#execute', :clean_gitlab_redis_shared_state do
subject { service.execute }
......@@ -76,22 +72,6 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'returns early', 'CI minutes limit not enabled for build'
end
context 'when project is not on Free plan' do
before do
create(:gitlab_subscription, :premium, namespace: namespace)
end
it_behaves_like 'returns early', 'Project is not on Free or trial plan'
end
context 'when running on self-hosted' do
before do
allow(Gitlab).to receive(:com?).and_return(false)
end
it_behaves_like 'returns early', 'Project is not on Free or trial plan'
end
context 'when shared runners limit is not enabled for build' do
before do
allow(build).to receive(:shared_runners_minutes_limit_enabled?).and_return(false)
......@@ -143,6 +123,14 @@ RSpec.describe Ci::Minutes::TrackLiveConsumptionService do
it_behaves_like 'limit exceeded'
end
context 'when namespace is on a paid plan' do
before do
create(:gitlab_subscription, :premium, namespace: namespace)
end
it_behaves_like 'limit exceeded'
end
context 'when feature flag is disabled' do
before do
stub_feature_flags(ci_minutes_track_live_consumption: false)
......
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