Commit afd2b31f authored by Nick Thomas's avatar Nick Thomas

Merge branch 'rename-license-cloud-method' into 'master'

Rename License#cloud? to License#cloud_license?

See merge request gitlab-org/gitlab!60065
parents 6abd47a3 1a30d9ee
...@@ -31,7 +31,7 @@ class Admin::LicensesController < Admin::ApplicationController ...@@ -31,7 +31,7 @@ class Admin::LicensesController < Admin::ApplicationController
@license = License.new(license_params) @license = License.new(license_params)
return upload_license_error if @license.cloud? return upload_license_error if @license.cloud_license?
respond_with(@license, location: admin_license_path) do respond_with(@license, location: admin_license_path) do
if @license.save if @license.save
......
...@@ -29,7 +29,7 @@ module Gitlab ...@@ -29,7 +29,7 @@ module Gitlab
def should_sync_seats? def should_sync_seats?
return false unless license return false unless license
if license.cloud? if license.cloud_license?
!license.trial? && !license.trial? &&
license.expires_at.present? # Skip sync if license has no expiration license.expires_at.present? # Skip sync if license has no expiration
else else
......
...@@ -550,12 +550,12 @@ class License < ApplicationRecord ...@@ -550,12 +550,12 @@ class License < ApplicationRecord
starts_at > Date.current starts_at > Date.current
end end
def cloud? def cloud_license?
license&.type == CLOUD_LICENSE_TYPE license&.type == CLOUD_LICENSE_TYPE
end end
def license_type def license_type
cloud? ? CLOUD_LICENSE_TYPE : LEGACY_LICENSE_TYPE cloud_license? ? CLOUD_LICENSE_TYPE : LEGACY_LICENSE_TYPE
end end
def auto_renew def auto_renew
...@@ -638,7 +638,7 @@ class License < ApplicationRecord ...@@ -638,7 +638,7 @@ class License < ApplicationRecord
end end
def check_users_limit def check_users_limit
return if cloud? return if cloud_license?
return unless restricted_user_count return unless restricted_user_count
if previous_user_count && (prior_historical_max <= previous_user_count) if previous_user_count && (prior_historical_max <= previous_user_count)
......
...@@ -10,7 +10,7 @@ module Licenses ...@@ -10,7 +10,7 @@ module Licenses
def execute def execute
raise ActiveRecord::RecordNotFound unless license raise ActiveRecord::RecordNotFound unless license
raise Gitlab::Access::AccessDeniedError unless can?(user, :destroy_licenses) raise Gitlab::Access::AccessDeniedError unless can?(user, :destroy_licenses)
raise DestroyCloudLicenseError.new(_('Cloud licenses can not be removed.')) if license.cloud? raise DestroyCloudLicenseError.new(_('Cloud licenses can not be removed.')) if license.cloud_license?
license.destroy license.destroy
end end
......
---
title: Rename License#cloud? to License#cloud_license?
merge_request: 60065
author:
type: fixed
...@@ -1407,8 +1407,8 @@ RSpec.describe License do ...@@ -1407,8 +1407,8 @@ RSpec.describe License do
end end
end end
describe '#cloud?' do describe '#cloud_license?' do
subject { license.cloud? } subject { license.cloud_license? }
context 'when no license provided' do context 'when no license provided' do
before do before 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