Commit 4e9666d1 authored by Dmitry Gruzd's avatar Dmitry Gruzd

Merge branch '327226_activated_at_fallback' into 'master'

Use actual activated at value for license type

See merge request gitlab-org/gitlab!59284
parents 530d2c39 3580d122
......@@ -300,7 +300,7 @@ gem 'gon', '~> 6.4.0'
gem 'request_store', '~> 1.5'
gem 'base32', '~> 0.3.0'
gem "gitlab-license", "~> 1.3"
gem "gitlab-license", "~> 1.4"
# Protect against bruteforcing
gem 'rack-attack', '~> 6.3.0'
......
......@@ -475,7 +475,7 @@ GEM
opentracing (~> 0.4)
pg_query (~> 1.3)
redis (> 3.0.0, < 5.0.0)
gitlab-license (1.3.1)
gitlab-license (1.4.0)
gitlab-mail_room (0.0.9)
gitlab-markup (1.7.1)
gitlab-net-dns (0.9.1)
......@@ -1437,7 +1437,7 @@ DEPENDENCIES
gitlab-fog-azure-rm (~> 1.0.1)
gitlab-fog-google (~> 1.13)
gitlab-labkit (~> 0.16.2)
gitlab-license (~> 1.3)
gitlab-license (~> 1.4)
gitlab-mail_room (~> 0.0.9)
gitlab-markup (~> 1.7.1)
gitlab-net-dns (~> 0.9.1)
......
......@@ -37,8 +37,7 @@ module Types
description: 'Date when the license expires.'
field :activated_at, ::Types::DateType, null: true,
description: 'Date when the license was activated.',
method: :created_at
description: 'Date when the license was activated.'
field :users_in_license_count, GraphQL::INT_TYPE, null: true,
description: 'Number of paid users in the license.',
......
......@@ -589,6 +589,10 @@ class License < ApplicationRecord
end
end
def activated_at
super || created_at
end
private
def restricted_attr(name, default = nil)
......
......@@ -1523,4 +1523,25 @@ RSpec.describe License do
it { is_expected.to eq('Example Inc.') }
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
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