Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ee626520
Commit
ee626520
authored
Jun 15, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Don't track historical data when there isn't a license or it's trial
parent
43a570dc
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
0 deletions
+67
-0
app/models/license.rb
app/models/license.rb
+4
-0
app/workers/historical_data_worker.rb
app/workers/historical_data_worker.rb
+2
-0
spec/factories/licenses.rb
spec/factories/licenses.rb
+10
-0
spec/workers/historical_data_worker_spec.rb
spec/workers/historical_data_worker_spec.rb
+51
-0
No files found.
app/models/license.rb
View file @
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
)
...
...
app/workers/historical_data_worker.rb
View file @
ee626520
...
...
@@ -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
spec/factories/licenses.rb
View file @
ee626520
...
...
@@ -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
spec/workers/historical_data_worker_spec.rb
0 → 100644
View file @
ee626520
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment