Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
nexedi
gitlab-ce
Commits
06e03f6e
Unverified
Commit
06e03f6e
authored
6 years ago
by
Douglas Barbosa Alexandre
Browse files
Options
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 @@ def persisted?(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
)
...
...
This diff is collapsed.
Click to expand it.
spec/lib/feature_spec.rb
View file @
06e03f6e
...
...
@@ -39,18 +39,36 @@
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
...
...
This diff is collapsed.
Click to expand it.
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