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
06e03f6e
Commit
06e03f6e
authored
Jul 19, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow feature flag names to be a symbol
parent
b60364c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
lib/feature.rb
lib/feature.rb
+1
-1
spec/lib/feature_spec.rb
spec/lib/feature_spec.rb
+25
-7
No files found.
lib/feature.rb
View file @
06e03f6e
...
...
@@ -39,7 +39,7 @@ class Feature
# Flipper creates on-memory features when asked for a not-yet-created one.
# If we want to check if a feature has been actually set, we look for it
# on the persisted features list.
persisted_names
.
include?
(
feature
.
name
)
persisted_names
.
include?
(
feature
.
name
.
to_s
)
end
def
enabled?
(
key
,
thing
=
nil
)
...
...
spec/lib/feature_spec.rb
View file @
06e03f6e
...
...
@@ -39,18 +39,36 @@ describe Feature do
end
describe
'.persisted?'
do
it
'returns true for a persisted feature'
do
Feature
::
FlipperFeature
.
create!
(
key:
'foo'
)
context
'when the feature is persisted'
do
it
'returns true when feature name is a string'
do
Feature
::
FlipperFeature
.
create!
(
key:
'foo'
)
feature
=
double
(
:feature
,
name:
'foo'
)
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
true
)
end
it
'returns true when feature name is a symbol'
do
Feature
::
FlipperFeature
.
create!
(
key:
'foo'
)
feature
=
double
(
:feature
,
name:
'foo'
)
feature
=
double
(
:feature
,
name: :foo
)
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
true
)
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
true
)
end
end
it
'returns false for a feature that is not persisted'
do
feature
=
double
(
:feature
,
name:
'foo'
)
context
'when the feature is not persisted'
do
it
'returns false when feature name is a string'
do
feature
=
double
(
:feature
,
name:
'foo'
)
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
false
)
end
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
false
)
it
'returns false when feature name is a symbol'
do
feature
=
double
(
:feature
,
name: :bar
)
expect
(
described_class
.
persisted?
(
feature
)).
to
eq
(
false
)
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