Commit 97c5bf70 authored by Mark Chao's avatar Mark Chao

Merge branch 'vshumilo-disable-sync-if-offline' into 'master'

Disable sync for offline cloud licenses

See merge request gitlab-org/gitlab!78728
parents c33e9f29 6184e401
......@@ -28,6 +28,7 @@ module Gitlab
def should_sync_seats?
return false unless license&.cloud_license?
return false if license.offline_cloud_license?
!license.trial? && license.expires_at.present? # Skip sync if license has no expiration
end
......
......@@ -584,6 +584,10 @@ class License < ApplicationRecord
!!license&.cloud_licensing?
end
def offline_cloud_license?
!!license&.offline_cloud_licensing?
end
def customer_service_enabled?
!!license&.operational_metrics?
end
......
......@@ -19,6 +19,14 @@ FactoryBot.define do
cloud_licensing_enabled { true }
end
trait :offline_enabled do
offline_cloud_licensing_enabled { true }
end
trait :offline_disabled do
offline_cloud_licensing_enabled { false }
end
transient do
plan { License::STARTER_PLAN }
end
......
......@@ -166,14 +166,26 @@ RSpec.describe Gitlab::SeatLinkData do
it { is_expected.to be_falsey }
end
context 'when not a cloud license' do
let(:license) { build(:license) }
it { is_expected.to be_falsey }
end
context 'when cloud license for offline use' do
let(:license) { build(:license, cloud: true, offline_cloud_licensing_enabled: true) }
it { is_expected.to be_falsey }
end
context 'when expires_at is not set' do
let(:license) { build(:license, expires_at: nil) }
let(:license) { build(:license, cloud: true, expires_at: nil) }
it { is_expected.to be_falsey }
end
context 'when license is trial' do
let(:license) { build(:license, trial: true) }
let(:license) { build(:license, cloud: true, trial: true) }
it { is_expected.to be_falsey }
end
......
......@@ -1486,6 +1486,36 @@ RSpec.describe License do
end
end
describe '#offline_cloud_license?' do
subject { license.offline_cloud_license? }
context 'when no license provided' do
before do
license.data = nil
end
it { is_expected.to be false }
end
context 'when the license has offline cloud licensing disabled' do
let(:gl_license) { build(:gitlab_license, :cloud, :offline_disabled) }
it { is_expected.to be false }
end
context 'when the license has offline cloud licensing enabled' do
let(:gl_license) { build(:gitlab_license, :cloud, :offline_enabled) }
it { is_expected.to be true }
end
context 'when the license offline cloud licensing is not set' do
let(:gl_license) { build(:gitlab_license, :cloud) }
it { is_expected.to be false }
end
end
describe '#customer_service_enabled?' do
subject { license.customer_service_enabled? }
......
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