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
9376a5a0
Commit
9376a5a0
authored
Jun 20, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only block changes when a regular license has expired
parent
ddd47d9e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
16 deletions
+52
-16
app/models/license.rb
app/models/license.rb
+4
-1
spec/factories/licenses.rb
spec/factories/licenses.rb
+29
-12
spec/models/license_spec.rb
spec/models/license_spec.rb
+18
-2
spec/workers/historical_data_worker_spec.rb
spec/workers/historical_data_worker_spec.rb
+1
-1
No files found.
app/models/license.rb
View file @
9376a5a0
...
...
@@ -157,7 +157,10 @@ class License < ActiveRecord::Base
end
def
block_changes?
!
current
||
current
.
block_changes?
return
false
if
current
.
nil?
return
false
if
License
&
.
current
&
.
trial?
current
.
block_changes?
end
def
load_license
...
...
spec/factories/licenses.rb
View file @
9376a5a0
FactoryGirl
.
define
do
factory
:gitlab_license
,
class:
"Gitlab::License"
do
trait
:trial
do
restrictions
do
{
trial:
true
}
end
end
trait
:expired
do
expires_at
{
3
.
weeks
.
ago
.
to_date
}
end
starts_at
{
Date
.
today
-
1
.
month
}
expires_at
{
Date
.
today
+
11
.
months
}
block_changes_at
{
expires_at
+
2
.
weeks
}
notify_users_at
{
expires_at
}
notify_admins_at
{
expires_at
}
licensee
do
{
"Name"
=>
generate
(
:name
)
}
end
restrictions
do
{
add_ons:
{
...
...
@@ -13,21 +28,23 @@ 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
transient
do
expired
false
trial
false
end
data
do
attrs
=
[
:gitlab_license
]
attrs
<<
:trial
if
trial
attrs
<<
:expired
if
expired
build
(
*
attrs
).
export
end
factory
:trial_license
,
class:
License
do
data
{
build
(
:gitlab_license
,
:trial
).
export
}
# Disable validations when creating an expired license key
to_create
{
|
instance
|
instance
.
save
(
validate:
!
expired
)
}
end
end
spec/models/license_spec.rb
View file @
9376a5a0
...
...
@@ -292,8 +292,24 @@ describe License do
allow
(
described_class
).
to
receive
(
:current
).
and_return
(
nil
)
end
it
"returns true"
do
expect
(
described_class
.
block_changes?
).
to
be_truthy
it
"returns false"
do
expect
(
described_class
.
block_changes?
).
to
eq
(
false
)
end
end
context
'with an expired trial license'
do
let!
(
:license
)
{
create
(
:license
,
trial:
true
)
}
it
'returns false'
do
expect
(
described_class
.
block_changes?
).
to
eq
(
false
)
end
end
context
'with an expired normal license'
do
let!
(
:license
)
{
create
(
:license
,
expired:
true
)
}
it
'returns true'
do
expect
(
described_class
.
block_changes?
).
to
eq
(
true
)
end
end
...
...
spec/workers/historical_data_worker_spec.rb
View file @
9376a5a0
...
...
@@ -6,7 +6,7 @@ describe HistoricalDataWorker do
describe
'#perform'
do
context
'with a trial license'
do
before
do
FactoryGirl
.
create
(
:
trial_licens
e
)
FactoryGirl
.
create
(
:
license
,
trial:
tru
e
)
end
it
'does not track historical data'
do
...
...
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