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
28df9ada
Commit
28df9ada
authored
Jul 06, 2017
by
Ruben Davila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Small refactor and fixes from last code review
parent
482eebb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
19 deletions
+22
-19
app/controllers/trials_controller.rb
app/controllers/trials_controller.rb
+1
-3
app/models/license.rb
app/models/license.rb
+7
-6
app/views/admin/licenses/missing.html.haml
app/views/admin/licenses/missing.html.haml
+1
-1
spec/models/license_spec.rb
spec/models/license_spec.rb
+13
-9
No files found.
app/controllers/trials_controller.rb
View file @
28df9ada
...
...
@@ -36,9 +36,7 @@ class TrialsController < ApplicationController
end
def
check_presence_of_license
current_license
=
License
.
current
if
current_license
&&
!
current_license
.
expired?
if
License
.
current
&
.
active?
redirect_to
admin_license_url
end
end
...
...
app/models/license.rb
View file @
28df9ada
...
...
@@ -157,10 +157,7 @@ class License < ActiveRecord::Base
end
def
block_changes?
return
false
if
current
.
nil?
return
false
if
current
.
trial?
current
.
block_changes?
!!
current
&
.
block_changes?
end
def
load_license
...
...
@@ -226,8 +223,6 @@ class License < ActiveRecord::Base
# keep `add_ons`, therefore this method needs to be backward-compatible in that sense.
# See https://gitlab.com/gitlab-org/gitlab-ee/issues/2019
def
add_ons
return
{}
if
trial?
&&
expired?
explicit_add_ons
=
restricted_attr
(
:add_ons
,
{})
plan_features
=
self
.
class
.
features_for_plan
(
plan
)
...
...
@@ -235,6 +230,8 @@ class License < ActiveRecord::Base
end
def
feature_available?
(
code
)
return
false
if
trial?
&&
expired?
feature
=
FEATURE_CODES
.
fetch
(
code
)
add_ons
[
feature
].
to_i
>
0
end
...
...
@@ -265,6 +262,10 @@ class License < ActiveRecord::Base
restricted_attr
(
:trial
)
end
def
active?
!
expired?
end
def
remaining_days
return
0
if
expired?
...
...
app/views/admin/licenses/missing.html.haml
View file @
28df9ada
...
...
@@ -9,7 +9,7 @@
%h4
You do not have a license.
%p
You can start a
30 day free trial for all premium feature
s.
%p
You can start a
free trial of GitLab Enterprise Edition without any obligation or payment detail
s.
=
link_to
'Start free trial'
,
new_trial_url
,
class:
"btn btn-new"
spec/models/license_spec.rb
View file @
28df9ada
...
...
@@ -425,15 +425,6 @@ describe License do
expect
(
license
.
add_ons
.
keys
).
to
include
(
License
::
DEPLOY_BOARD_FEATURE
,
*
eep_features
)
end
end
context
'with an expired trial license'
do
it
'returns an empty Hash'
do
described_class
.
destroy_all
create
(
:license
,
trial:
true
,
expired:
true
)
expect
(
described_class
.
current
.
add_ons
).
to
be_empty
end
end
end
describe
'#feature_available?'
do
...
...
@@ -460,6 +451,19 @@ describe License do
expect
{
license
.
feature_available?
(
:invalid
)
}.
to
raise_error
(
KeyError
)
end
context
'with an expired trial license'
do
before
(
:all
)
do
described_class
.
destroy_all
create
(
:license
,
trial:
true
,
expired:
true
)
end
::
License
::
FEATURE_CODES
.
keys
do
|
feature_code
|
it
"returns false for
#{
feature_code
}
"
do
expect
(
license
.
feature_available?
(
feature_code
)).
to
eq
(
false
)
end
end
end
end
def
build_license_with_add_ons
(
add_ons
,
plan:
nil
)
...
...
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