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
4cc1c629
Commit
4cc1c629
authored
Oct 04, 2018
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature flag check in License.feature_available?
parent
c996b5e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
0 deletions
+23
-0
ee/app/models/license.rb
ee/app/models/license.rb
+3
-0
ee/spec/models/license_spec.rb
ee/spec/models/license_spec.rb
+20
-0
No files found.
ee/app/models/license.rb
View file @
4cc1c629
...
...
@@ -293,6 +293,9 @@ class License < ActiveRecord::Base
def
feature_available?
(
feature
)
return
false
if
trial?
&&
expired?
# This feature might not be behind a feature flag at all, so default to true
return
false
unless
::
Feature
.
enabled?
(
feature
,
default_enabled:
true
)
features
.
include?
(
feature
)
end
...
...
ee/spec/models/license_spec.rb
View file @
4cc1c629
...
...
@@ -569,6 +569,26 @@ describe License do
end
end
end
context
'when feature is disabled by a feature flag'
do
it
'returns false'
do
feature
=
license
.
features
.
first
stub_feature_flags
(
feature
=>
false
)
expect
(
license
.
features
).
not_to
receive
(
:include?
)
expect
(
license
.
feature_available?
(
feature
)).
to
eq
(
false
)
end
end
context
'when feature is enabled by a feature flag'
do
it
'returns true'
do
feature
=
license
.
features
.
first
stub_feature_flags
(
feature
=>
true
)
expect
(
license
.
feature_available?
(
feature
)).
to
eq
(
true
)
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