Commit 3580d122 authored by Corinna Wiesner's avatar Corinna Wiesner

Use actual activated at value for license type

Prior to this change, the value for activated at in the GraphQL
Types::Admin::CloudLicenses::LicenseType class was using created at
since the field didn't exist before. Now that the field exists in the
Gitlab::License we can use the actual value and implement a fallback to
created at for older licenses.
parent f379f644
...@@ -298,7 +298,7 @@ gem 'gon', '~> 6.4.0' ...@@ -298,7 +298,7 @@ gem 'gon', '~> 6.4.0'
gem 'request_store', '~> 1.5' gem 'request_store', '~> 1.5'
gem 'base32', '~> 0.3.0' gem 'base32', '~> 0.3.0'
gem "gitlab-license", "~> 1.3" gem "gitlab-license", "~> 1.4"
# Protect against bruteforcing # Protect against bruteforcing
gem 'rack-attack', '~> 6.3.0' gem 'rack-attack', '~> 6.3.0'
......
...@@ -475,7 +475,7 @@ GEM ...@@ -475,7 +475,7 @@ GEM
opentracing (~> 0.4) opentracing (~> 0.4)
pg_query (~> 1.3) pg_query (~> 1.3)
redis (> 3.0.0, < 5.0.0) redis (> 3.0.0, < 5.0.0)
gitlab-license (1.3.1) gitlab-license (1.4.0)
gitlab-mail_room (0.0.9) gitlab-mail_room (0.0.9)
gitlab-markup (1.7.1) gitlab-markup (1.7.1)
gitlab-net-dns (0.9.1) gitlab-net-dns (0.9.1)
...@@ -1436,7 +1436,7 @@ DEPENDENCIES ...@@ -1436,7 +1436,7 @@ DEPENDENCIES
gitlab-fog-azure-rm (~> 1.0.1) gitlab-fog-azure-rm (~> 1.0.1)
gitlab-fog-google (~> 1.13) gitlab-fog-google (~> 1.13)
gitlab-labkit (~> 0.16.2) gitlab-labkit (~> 0.16.2)
gitlab-license (~> 1.3) gitlab-license (~> 1.4)
gitlab-mail_room (~> 0.0.9) gitlab-mail_room (~> 0.0.9)
gitlab-markup (~> 1.7.1) gitlab-markup (~> 1.7.1)
gitlab-net-dns (~> 0.9.1) gitlab-net-dns (~> 0.9.1)
......
...@@ -37,8 +37,7 @@ module Types ...@@ -37,8 +37,7 @@ module Types
description: 'Date when the license expires.' description: 'Date when the license expires.'
field :activated_at, ::Types::DateType, null: true, field :activated_at, ::Types::DateType, null: true,
description: 'Date when the license was activated.', description: 'Date when the license was activated.'
method: :created_at
field :users_in_license_count, GraphQL::INT_TYPE, null: true, field :users_in_license_count, GraphQL::INT_TYPE, null: true,
description: 'Number of paid users in the license.', description: 'Number of paid users in the license.',
......
...@@ -589,6 +589,10 @@ class License < ApplicationRecord ...@@ -589,6 +589,10 @@ class License < ApplicationRecord
end end
end end
def activated_at
super || created_at
end
private private
def restricted_attr(name, default = nil) def restricted_attr(name, default = nil)
......
...@@ -1523,4 +1523,25 @@ RSpec.describe License do ...@@ -1523,4 +1523,25 @@ RSpec.describe License do
it { is_expected.to eq('Example Inc.') } it { is_expected.to eq('Example Inc.') }
end end
describe '#activated_at' do
subject { license.activated_at }
let(:license) do
gl_license = build(:gitlab_license, activated_at: activated_at)
build(:license, data: gl_license.export, created_at: 5.days.ago)
end
context 'when activated_at is set within the license data' do
let(:activated_at) { Date.yesterday.to_datetime }
it { is_expected.to eq(activated_at) }
end
context 'when activated_at is not set within the license data' do
let(:activated_at) { nil }
it { is_expected.to eq(license.created_at) }
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