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
45525eb0
Commit
45525eb0
authored
Feb 19, 2021
by
jejacks0n
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Stub gitlab-experiment config.cache in before each
- This shifts the stubbing behavior to all specs instead of a few.
parent
dc9c2c37
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
config/initializers/gitlab_experiment.rb
config/initializers/gitlab_experiment.rb
+3
-7
spec/experiments/application_experiment_spec.rb
spec/experiments/application_experiment_spec.rb
+3
-3
spec/support/gitlab_experiment.rb
spec/support/gitlab_experiment.rb
+6
-2
No files found.
config/initializers/gitlab_experiment.rb
View file @
45525eb0
# frozen_string_literal: true
Gitlab
::
Experiment
.
configure
do
|
config
|
config
.
define_singleton_method
(
:_default_cache
)
do
Gitlab
::
Experiment
::
Cache
::
RedisHashStore
.
new
(
config
.
base_class
=
'ApplicationExperiment'
config
.
cache
=
Gitlab
::
Experiment
::
Cache
::
RedisHashStore
.
new
(
pool:
->
(
&
block
)
{
Gitlab
::
Redis
::
SharedState
.
with
{
|
redis
|
block
.
call
(
redis
)
}
}
)
end
config
.
base_class
=
'ApplicationExperiment'
config
.
cache
=
config
.
_default_cache
end
spec/experiments/application_experiment_spec.rb
View file @
45525eb0
...
...
@@ -191,15 +191,15 @@ RSpec.describe ApplicationExperiment, :experiment do
end
context
"when caching"
do
let
(
:cache
)
{
Gitlab
::
Experiment
::
Configuration
.
_default_cache
}
# as defined in the initializer
let
(
:cache
)
{
Gitlab
::
Experiment
::
Configuration
.
cache
}
before
do
allow
(
Gitlab
::
Experiment
::
Configuration
).
to
receive
(
:cache
).
and_call_original
cache
.
clear
(
key:
subject
.
name
)
subject
.
use
{
}
# setup the control
subject
.
try
{
}
# setup the candidate
allow
(
Gitlab
::
Experiment
::
Configuration
).
to
receive
(
:cache
).
and_return
(
cache
)
end
it
"caches the variant determined by the variant resolver"
do
...
...
spec/support/gitlab_experiment.rb
View file @
45525eb0
...
...
@@ -12,5 +12,9 @@ class ApplicationExperiment < Gitlab::Experiment # rubocop:disable Gitlab/Namesp
end
end
# Disable all caching for experiments in tests.
Gitlab
::
Experiment
::
Configuration
.
cache
=
nil
RSpec
.
configure
do
|
config
|
# Disable all caching for experiments in tests.
config
.
before
do
allow
(
Gitlab
::
Experiment
::
Configuration
).
to
receive
(
:cache
).
and_return
(
nil
)
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