Commit 06974041 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'fix-trial-max-historical-tracking' into 'master'

Don't track historical data when license is trial

See merge request !2138
parents 2400f320 ee626520
...@@ -203,6 +203,10 @@ class License < ActiveRecord::Base ...@@ -203,6 +203,10 @@ class License < ActiveRecord::Base
restricted_attr(:trueup_to)].all?(&:present?) restricted_attr(:trueup_to)].all?(&:present?)
end end
def trial?
restricted_attr(:trial)
end
private private
def restricted_attr(name, default = nil) def restricted_attr(name, default = nil)
......
...@@ -4,6 +4,8 @@ class HistoricalDataWorker ...@@ -4,6 +4,8 @@ class HistoricalDataWorker
def perform def perform
return if Gitlab::Geo.secondary? return if Gitlab::Geo.secondary?
return if License.current.nil? || License.current&.trial?
HistoricalData.track! HistoricalData.track!
end end
end end
...@@ -15,9 +15,19 @@ FactoryGirl.define do ...@@ -15,9 +15,19 @@ FactoryGirl.define do
end end
notify_users_at { |l| l.expires_at } notify_users_at { |l| l.expires_at }
notify_admins_at { |l| l.expires_at } notify_admins_at { |l| l.expires_at }
trait :trial do
restrictions do
{ trial: true }
end
end
end end
factory :license do factory :license do
data { build(:gitlab_license).export } data { build(:gitlab_license).export }
end end
factory :trial_license, class: License do
data { build(:gitlab_license, :trial).export }
end
end end
require 'spec_helper'
describe HistoricalDataWorker do
subject { described_class.new }
describe '#perform' do
context 'with a trial license' do
before do
FactoryGirl.create(:trial_license)
end
it 'does not track historical data' do
expect(HistoricalData).not_to receive(:track!)
subject.perform
end
end
context 'with a non trial license' do
before do
FactoryGirl.create(:license)
end
it 'tracks historical data' do
expect(HistoricalData).to receive(:track!)
subject.perform
end
end
context 'with a Geo secondary node' do
it 'does not track historical data' do
allow(Gitlab::Geo).to receive(:secondary?).and_return(true)
expect(HistoricalData).not_to receive(:track!)
subject.perform
end
end
context 'when there is not a license key' do
it 'does not track historical data' do
License.destroy_all
expect(HistoricalData).not_to receive(:track!)
subject.perform
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