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
Boxiang Sun
gitlab-ce
Commits
db7dabea
Commit
db7dabea
authored
May 17, 2019
by
Luke Duncalfe
Committed by
Achilleas Pipinellis
May 17, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Link to testing guide for feature flag spec info
In order for there to be a single source of truth.
parent
8739c009
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
4 deletions
+34
-4
doc/development/feature_flags.md
doc/development/feature_flags.md
+4
-4
doc/development/testing_guide/best_practices.md
doc/development/testing_guide/best_practices.md
+30
-0
No files found.
doc/development/feature_flags.md
View file @
db7dabea
...
@@ -108,11 +108,11 @@ so we make sure behavior under feature flag doesn't go untested in some non-spec
...
@@ -108,11 +108,11 @@ so we make sure behavior under feature flag doesn't go untested in some non-spec
contexts.
contexts.
Whenever a feature flag is present, make sure to test _both_ states of the
Whenever a feature flag is present, make sure to test _both_ states of the
feature flag.
You can stub a feature flag as follows:
feature flag.
```
ruby
See the
stub_feature_flags
(
my_feature_flag:
false
)
[
testing guide
](
testing_guide/best_practices.html#feature-flags-in-tests
)
```
for information and examples on how to stub feature flags in tests.
## Enabling a feature flag (in development)
## Enabling a feature flag (in development)
...
...
doc/development/testing_guide/best_practices.md
View file @
db7dabea
...
@@ -240,6 +240,36 @@ it 'is overdue' do
...
@@ -240,6 +240,36 @@ it 'is overdue' do
end
end
```
```
### Feature flags in tests
All feature flags are stubbed to be enabled by default in our Ruby-based
tests.
To disable a feature flag in a test, use the
`stub_feature_flags`
helper. For example, to globally disable the
`ci_live_trace`
feature
flag in a test:
```
ruby
stub_feature_flags
(
ci_live_trace:
false
)
Feature
.
enabled?
(
:ci_live_trace
)
# => false
```
If you wish to set up a test where a feature flag is disabled for some
actors and not others, you can specify this in options passed to the
helper. For example, to disable the
`ci_live_trace`
feature flag for a
specifc project:
```
ruby
project1
,
project2
=
build_list
(
:project
,
2
)
# Feature will only be disabled for project1
stub_feature_flags
(
ci_live_trace:
{
enabled:
false
,
thing:
project1
})
Feature
.
enabled?
(
:ci_live_trace
,
project1
)
# => false
Feature
.
enabled?
(
:ci_live_trace
,
project2
)
# => true
```
### Pristine test environments
### Pristine test environments
The code exercised by a single GitLab test may access and modify many items of
The code exercised by a single GitLab test may access and modify many items of
...
...
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