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
231887f4
Commit
231887f4
authored
Jul 12, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use YAML default state in GraphQL feature flags
parent
44a778a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
12 deletions
+34
-12
app/graphql/types/base_field.rb
app/graphql/types/base_field.rb
+1
-1
spec/graphql/features/feature_flag_spec.rb
spec/graphql/features/feature_flag_spec.rb
+16
-5
spec/graphql/types/base_field_spec.rb
spec/graphql/types/base_field_spec.rb
+17
-6
No files found.
app/graphql/types/base_field.rb
View file @
231887f4
...
...
@@ -65,7 +65,7 @@ module Types
end
def
visible?
(
context
)
return
false
if
feature_flag
.
present?
&&
!
Feature
.
enabled?
(
feature_flag
)
return
false
if
feature_flag
.
present?
&&
!
Feature
.
enabled?
(
feature_flag
,
default_enabled: :yaml
)
super
end
...
...
spec/graphql/features/feature_flag_spec.rb
View file @
231887f4
...
...
@@ -28,14 +28,25 @@ RSpec.describe 'Graphql Field feature flags' do
end
end
it
'returns the value when feature is enabled'
do
expect
(
subject
[
'item'
]).
to
eq
(
'name'
=>
test_object
.
name
)
it
'checks YAML definition for default_enabled'
do
# Exception is indicative of a check for YAML definition
expect
{
subject
}.
to
raise_error
(
Feature
::
InvalidFeatureFlagError
,
/The feature flag YAML definition for '
#{
feature_flag
}
' does not exist/
)
end
it
'returns nil when the feature is disabled'
do
stub_feature_flags
(
feature_flag
=>
false
)
context
'skipping YAML check'
do
before
do
skip_default_enabled_yaml_check
end
it
'returns the value when feature is enabled'
do
expect
(
subject
[
'item'
]).
to
eq
(
'name'
=>
test_object
.
name
)
end
expect
(
subject
).
to
be_nil
it
'returns nil when the feature is disabled'
do
stub_feature_flags
(
feature_flag
=>
false
)
expect
(
subject
).
to
be_nil
end
end
end
end
spec/graphql/types/base_field_spec.rb
View file @
231887f4
...
...
@@ -130,14 +130,25 @@ RSpec.describe Types::BaseField do
skip_feature_flags_yaml_validation
end
it
'returns false if the feature is not enabled'
do
stub_feature_flags
(
flag
=>
false
)
expect
(
field
.
visible?
(
context
)).
to
eq
(
false
)
it
'checks YAML definition for default_enabled'
do
# Exception is indicative of a check for YAML definition
expect
{
field
.
visible?
(
context
)
}.
to
raise_error
(
Feature
::
InvalidFeatureFlagError
,
/The feature flag YAML definition for '
#{
flag
}
' does not exist/
)
end
it
'returns true if the feature is enabled'
do
expect
(
field
.
visible?
(
context
)).
to
eq
(
true
)
context
'skipping YAML check'
do
before
do
skip_default_enabled_yaml_check
end
it
'returns false if the feature is not enabled'
do
stub_feature_flags
(
flag
=>
false
)
expect
(
field
.
visible?
(
context
)).
to
eq
(
false
)
end
it
'returns true if the feature is enabled'
do
expect
(
field
.
visible?
(
context
)).
to
eq
(
true
)
end
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