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
restricted_attr(:trueup_to)].all?(&:present?)
end
def trial?
restricted_attr(:trial)
end
private
def restricted_attr(name, default = nil)
......
......@@ -4,6 +4,8 @@ class HistoricalDataWorker
def perform
return if Gitlab::Geo.secondary?
return if License.current.nil? || License.current&.trial?
HistoricalData.track!
end
end
......@@ -15,9 +15,19 @@ FactoryGirl.define do
end
notify_users_at { |l| l.expires_at }
notify_admins_at { |l| l.expires_at }
trait :trial do
restrictions do
{ trial: true }
end
end
end
factory :license do
data { build(:gitlab_license).export }
end
factory :trial_license, class: License do
data { build(:gitlab_license, :trial).export }
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