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
91939400
Commit
91939400
authored
Apr 21, 2020
by
Jason Goodman
Committed by
Shinya Maeda
Apr 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always return new version feature flags to Unleash clients
Ignore state of feature_flags_new_version feature flag
parent
2d41405b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
45 deletions
+3
-45
ee/lib/api/unleash.rb
ee/lib/api/unleash.rb
+3
-6
ee/spec/requests/api/unleash_spec.rb
ee/spec/requests/api/unleash_spec.rb
+0
-39
No files found.
ee/lib/api/unleash.rb
View file @
91939400
...
...
@@ -72,13 +72,10 @@ module API
def
feature_flags
return
[]
unless
unleash_app_name
.
present?
flags
=
Operations
::
FeatureFlagScope
.
for_unleash_client
(
project
,
unleash_app_name
)
legacy_flags
=
Operations
::
FeatureFlagScope
.
for_unleash_client
(
project
,
unleash_app_name
)
new_version_flags
=
Operations
::
FeatureFlag
.
for_unleash_client
(
project
,
unleash_app_name
)
if
Feature
.
enabled?
(
:feature_flags_new_version
,
project
)
flags
+=
Operations
::
FeatureFlag
.
for_unleash_client
(
project
,
unleash_app_name
)
end
flags
legacy_flags
+
new_version_flags
end
end
end
...
...
ee/spec/requests/api/unleash_spec.rb
View file @
91939400
...
...
@@ -277,20 +277,6 @@ describe API::Unleash do
end
context
'with version 2 feature flags'
do
it
'does not return any flags when the feature flag is disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
feature_flag
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'feature1'
,
active:
true
,
version:
2
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
feature_flag
,
name:
'default'
,
parameters:
{})
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'production'
)
get
api
(
features_url
),
headers:
{
'UNLEASH-INSTANCEID'
=>
client
.
token
,
'UNLEASH-APPNAME'
=>
'production'
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'features'
]).
to
eq
([])
end
it
'does not return a flag without any strategies'
do
create
(
:operations_feature_flag
,
project:
project
,
name:
'feature1'
,
active:
true
,
version:
2
)
...
...
@@ -511,31 +497,6 @@ describe API::Unleash do
end
context
'when mixing version 1 and version 2 feature flags'
do
it
'returns only version 1 flags when the new flags are disabled'
do
stub_feature_flags
(
feature_flags_new_version:
false
)
feature_flag_a
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'feature_a'
,
active:
true
,
version:
2
)
strategy
=
create
(
:operations_strategy
,
feature_flag:
feature_flag_a
,
name:
'userWithId'
,
parameters:
{
userIds:
'user8'
})
create
(
:operations_scope
,
strategy:
strategy
,
environment_scope:
'staging'
)
feature_flag_b
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'feature_b'
,
active:
true
,
version:
1
)
create
(
:operations_feature_flag_scope
,
feature_flag:
feature_flag_b
,
active:
true
,
strategies:
[{
name:
'default'
,
parameters:
{}
}],
environment_scope:
'staging'
)
get
api
(
features_url
),
headers:
{
'UNLEASH-INSTANCEID'
=>
client
.
token
,
'UNLEASH-APPNAME'
=>
'staging'
}
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
json_response
[
'features'
].
sort_by
{
|
f
|
f
[
'name'
]}).
to
eq
([{
'name'
=>
'feature_b'
,
'enabled'
=>
true
,
'strategies'
=>
[{
'name'
=>
'default'
,
'parameters'
=>
{}
}]
}])
end
it
'returns both types of flags when both match'
do
feature_flag_a
=
create
(
:operations_feature_flag
,
project:
project
,
name:
'feature_a'
,
active:
true
,
version:
2
)
...
...
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