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
771e0506
Commit
771e0506
authored
Jan 27, 2021
by
jejacks0n
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the default enabled as specified in the yaml
parent
58c2c643
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
1 deletion
+15
-1
app/experiments/application_experiment.rb
app/experiments/application_experiment.rb
+1
-1
spec/experiments/application_experiment_spec.rb
spec/experiments/application_experiment_spec.rb
+14
-0
No files found.
app/experiments/application_experiment.rb
View file @
771e0506
...
...
@@ -26,7 +26,7 @@ class ApplicationExperiment < Gitlab::Experiment
private
def
resolve_variant_name
return
variant_names
.
first
if
Feature
.
enabled?
(
name
,
self
,
type: :experiment
)
return
variant_names
.
first
if
Feature
.
enabled?
(
name
,
self
,
type: :experiment
,
default_enabled: :yaml
)
nil
# Returning nil vs. :control is important for not caching and rollouts.
end
...
...
spec/experiments/application_experiment_spec.rb
View file @
771e0506
...
...
@@ -5,6 +5,14 @@ require 'spec_helper'
RSpec
.
describe
ApplicationExperiment
,
:experiment
do
subject
{
described_class
.
new
(
:stub
)
}
let
(
:feature_definition
)
{
{
name:
'stub'
,
type:
'experiment'
,
group:
'group::adoption'
,
default_enabled:
false
}
}
around
do
|
example
|
Feature
::
Definition
.
definitions
[
:stub
]
=
Feature
::
Definition
.
new
(
'stub.yml'
,
feature_definition
)
example
.
run
Feature
::
Definition
.
definitions
.
delete
(
:stub
)
end
before
do
allow
(
subject
).
to
receive
(
:enabled?
).
and_return
(
true
)
end
...
...
@@ -105,6 +113,12 @@ RSpec.describe ApplicationExperiment, :experiment do
end
describe
"variant resolution"
do
it
"uses the default value as specified in the yaml"
do
expect
(
Feature
).
to
receive
(
:enabled?
).
with
(
'stub'
,
subject
,
type: :experiment
,
default_enabled: :yaml
)
expect
(
subject
.
variant
.
name
).
to
eq
(
'control'
)
end
it
"returns nil when not rolled out"
do
stub_feature_flags
(
stub:
false
)
...
...
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