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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
198f6965
Commit
198f6965
authored
Feb 13, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CE Backport: Fix unleash server side cannot return feature flags
Apply nice suggestions
parent
032e800b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
spec/support/helpers/stub_feature_flags.rb
spec/support/helpers/stub_feature_flags.rb
+23
-4
No files found.
spec/support/helpers/stub_feature_flags.rb
View file @
198f6965
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
|
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