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
815b5120
Commit
815b5120
authored
Feb 13, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unleash server side cannot return feature flags
Add changelog Improve coding style
parent
5c1e5f18
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
6 deletions
+47
-6
ee/changelogs/unreleased/fix-feature_flags_environment_scope-feature-flag.yml
...ased/fix-feature_flags_environment_scope-feature-flag.yml
+5
-0
ee/lib/api/unleash.rb
ee/lib/api/unleash.rb
+1
-1
ee/spec/requests/api/unleash_spec.rb
ee/spec/requests/api/unleash_spec.rb
+18
-1
spec/support/helpers/stub_feature_flags.rb
spec/support/helpers/stub_feature_flags.rb
+23
-4
No files found.
ee/changelogs/unreleased/fix-feature_flags_environment_scope-feature-flag.yml
0 → 100644
View file @
815b5120
---
title
:
Fix unleash server side cannot return feature flags
merge_request
:
9532
author
:
type
:
fixed
ee/lib/api/unleash.rb
View file @
815b5120
...
...
@@ -70,7 +70,7 @@ module API
end
def
feature_flags
if
Feature
.
enabled?
(
:feature_flags_environment_scope
,
project
:
project
)
if
Feature
.
enabled?
(
:feature_flags_environment_scope
,
project
)
return
[]
unless
unleash_app_name
.
present?
project
.
operations_feature_flags
.
for_environment
(
unleash_app_name
)
...
...
ee/spec/requests/api/unleash_spec.rb
View file @
815b5120
...
...
@@ -82,7 +82,6 @@ describe API::Unleash do
end
before
do
stub_feature_flags
(
feature_flags_environment_scope:
true
)
create_scope
(
feature_flag_1
,
'production'
,
false
)
create_scope
(
feature_flag_2
,
'review/*'
,
true
)
end
...
...
@@ -93,6 +92,24 @@ describe API::Unleash do
expect
(
recorded
.
count
).
to
be_within
(
8
).
of
(
10
)
end
it
'calls for_environment method'
do
expect
(
Operations
::
FeatureFlag
).
to
receive
(
:for_environment
)
subject
end
context
'when the feature is disabled on the project'
do
before
do
stub_feature_flags
(
feature_flags_environment_scope:
{
enabled:
false
,
thing:
project
})
end
it
'does not call for_environment method'
do
expect
(
Operations
::
FeatureFlag
).
not_to
receive
(
:for_environment
)
subject
end
end
context
'when app name is staging'
do
let
(
:headers
)
{
base_headers
.
merge
({
"UNLEASH-APPNAME"
=>
"staging"
})
}
...
...
spec/support/helpers/stub_feature_flags.rb
View file @
815b5120
module
StubFeatureFlags
# Stub Feature flags with `flag_name: true/false`
#
# @param [Hash] features where key is feature name and value is boolean whether enabled or not
# @param [Hash] features where key is feature name and value is boolean whether enabled or not.
# Alternatively, you can specify Hash to enable the flag on a specific thing.
#
# Examples
# - `stub_feature_flags(ci_live_trace: false)` ... Disable `ci_live_trace`
# feature flag globally.
# - `stub_feature_flags(ci_live_trace: { enabled: false, thing: project })` ...
# Disable `ci_live_trace` feature flag on the specified project.
def
stub_feature_flags
(
features
)
features
.
each
do
|
feature_name
,
enabled
|
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
,
any_args
)
{
enabled
}
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
.
to_s
,
any_args
)
{
enabled
}
features
.
each
do
|
feature_name
,
option
|
if
option
.
is_a?
(
Hash
)
enabled
,
thing
=
option
.
values_at
(
:enabled
,
:thing
)
else
enabled
=
option
thing
=
nil
end
if
thing
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
,
thing
,
any_args
)
{
enabled
}
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
.
to_s
,
thing
,
any_args
)
{
enabled
}
else
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
,
any_args
)
{
enabled
}
allow
(
Feature
).
to
receive
(
:enabled?
).
with
(
feature_name
.
to_s
,
any_args
)
{
enabled
}
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