Commit 6b2cfad0 authored by Stan Hu's avatar Stan Hu

Merge branch '297512-add-license-subscription_id-to-usage-ping' into 'master'

Add license subscription_id to  Usage Ping

See merge request gitlab-org/gitlab!51601
parents 64738843 44543aef
......@@ -388,6 +388,11 @@ class License < ApplicationRecord
restricted_attr(:add_ons, {})
end
# License zuora_subscription_id
def subscription_id
restricted_attr(:subscription_id)
end
def features_from_add_ons
add_ons.map { |name, count| FEATURES_FOR_ADD_ONS[name] if count.to_i > 0 }.compact
end
......
---
title: Add License subscription_id to Usage Ping
merge_request: 51601
author:
type: added
......@@ -102,6 +102,7 @@ module EE
usage_data[:license_plan] = license.plan
usage_data[:license_add_ons] = license.add_ons
usage_data[:license_trial] = license.trial?
usage_data[:license_subscription_id] = alt_usage_data(fallback: nil) { license.subscription_id }
end
usage_data
......
......@@ -35,7 +35,8 @@ FactoryBot.define do
'GitLab_FileLocks' => 1,
'GitLab_Auditor_User' => 1
},
plan: plan
plan: plan,
subscription_id: '0000'
}
end
end
......
......@@ -72,6 +72,7 @@ RSpec.describe Gitlab::UsageData do
license_starts_at
license_user_count
license_trial
license_subscription_id
licensee
license_md5
license_id
......@@ -189,6 +190,7 @@ RSpec.describe Gitlab::UsageData do
expect(subject[:license_expires_at]).to eq(license.expires_at)
expect(subject[:license_add_ons]).to eq(license.add_ons)
expect(subject[:license_trial]).to eq(license.trial?)
expect(subject[:license_subscription_id]).to eq(license.subscription_id)
end
end
......
......@@ -816,6 +816,15 @@ RSpec.describe License do
end
end
describe '#subscription_id' do
it 'has correct subscription_id' do
gl_license = build(:gitlab_license, restrictions: { subscription_id: "1111" })
license = build(:license, data: gl_license.export)
expect(license.subscription_id).to eq("1111")
end
end
describe '#daily_billable_users_count' do
before_all do
create(:group_member)
......
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