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
b3d88d8f
Commit
b3d88d8f
authored
Mar 05, 2021
by
Alex Buijs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save some time initialising a context every spec
parent
547ca286
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
4 additions
and
12 deletions
+4
-12
spec/spec_helper.rb
spec/spec_helper.rb
+1
-1
spec/support/shared_examples/lib/api/ci/runner_shared_examples.rb
...port/shared_examples/lib/api/ci/runner_shared_examples.rb
+1
-1
spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb
...quests/api/logging_application_context_shared_examples.rb
+2
-10
No files found.
spec/spec_helper.rb
View file @
b3d88d8f
...
@@ -304,7 +304,7 @@ RSpec.configure do |config|
...
@@ -304,7 +304,7 @@ RSpec.configure do |config|
RequestStore
.
clear!
RequestStore
.
clear!
end
end
config
.
around
do
|
example
|
config
.
around
(
:example
,
:context_aware
)
do
|
example
|
# Wrap each example in it's own context to make sure the contexts don't
# Wrap each example in it's own context to make sure the contexts don't
# leak
# leak
Gitlab
::
ApplicationContext
.
with_raw_context
{
example
.
run
}
Gitlab
::
ApplicationContext
.
with_raw_context
{
example
.
run
}
...
...
spec/support/shared_examples/lib/api/ci/runner_shared_examples.rb
View file @
b3d88d8f
# frozen_string_literal: true
# frozen_string_literal: true
RSpec
.
shared_examples
'API::CI::Runner application context metadata'
do
|
api_route
|
RSpec
.
shared_examples
'API::CI::Runner application context metadata'
do
|
api_route
|
it
'contains correct context metadata'
do
it
'contains correct context metadata'
,
:context_aware
do
# Avoids popping the context from the thread so we can
# Avoids popping the context from the thread so we can
# check its content after the request.
# check its content after the request.
allow
(
Labkit
::
Context
).
to
receive
(
:pop
)
allow
(
Labkit
::
Context
).
to
receive
(
:pop
)
...
...
spec/support/shared_examples/requests/api/logging_application_context_shared_examples.rb
View file @
b3d88d8f
# frozen_string_literal: true
# frozen_string_literal: true
RSpec
.
shared_examples
'storing arguments in the application context'
do
RSpec
.
shared_examples
'storing arguments in the application context'
do
around
do
|
example
|
it
'places the expected params in the application context'
,
:context_aware
do
Gitlab
::
ApplicationContext
.
with_base_context
{
example
.
run
}
end
it
'places the expected params in the application context'
do
# Stub the clearing of the context so we can validate it later
# Stub the clearing of the context so we can validate it later
# The `around` block above makes sure we do clean it up later
allow
(
Labkit
::
Context
).
to
receive
(
:pop
)
allow
(
Labkit
::
Context
).
to
receive
(
:pop
)
subject
subject
Gitlab
::
ApplicationContext
.
with_base_context
do
|
context
|
expect
(
Gitlab
::
ApplicationContext
.
current
).
to
include
(
log_hash
(
expected_params
))
expect
(
context
.
to_h
)
.
to
include
(
log_hash
(
expected_params
))
end
end
end
def
log_hash
(
hash
)
def
log_hash
(
hash
)
...
...
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