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
Jérome Perrin
gitlab-ce
Commits
34ba8039
Commit
34ba8039
authored
Jun 09, 2017
by
Oswaldo Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use :request_store hooks on specs
parent
ce37a209
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
82 deletions
+20
-82
spec/controllers/projects/jobs_controller_spec.rb
spec/controllers/projects/jobs_controller_spec.rb
+2
-9
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-6
spec/controllers/projects/pipelines_controller_spec.rb
spec/controllers/projects/pipelines_controller_spec.rb
+1
-8
spec/lib/banzai/filter/abstract_reference_filter_spec.rb
spec/lib/banzai/filter/abstract_reference_filter_spec.rb
+1
-10
spec/lib/banzai/issuable_extractor_spec.rb
spec/lib/banzai/issuable_extractor_spec.rb
+1
-10
spec/lib/banzai/reference_parser/user_parser_spec.rb
spec/lib/banzai/reference_parser/user_parser_spec.rb
+1
-10
spec/models/concerns/routable_spec.rb
spec/models/concerns/routable_spec.rb
+1
-10
spec/models/project_team_spec.rb
spec/models/project_team_spec.rb
+1
-10
spec/serializers/pipeline_serializer_spec.rb
spec/serializers/pipeline_serializer_spec.rb
+2
-9
spec/spec_helper.rb
spec/spec_helper.rb
+9
-0
No files found.
spec/controllers/projects/jobs_controller_spec.rb
View file @
34ba8039
...
...
@@ -69,18 +69,11 @@ describe Projects::JobsController do
Ci
::
Build
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_build
(
status
,
status
)
end
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
it
"verifies number of queries"
do
it
'verifies number of queries'
,
:request_store
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
get_index
}
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
8
)
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
7
)
end
def
create_build
(
name
,
status
)
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
34ba8039
...
...
@@ -119,10 +119,8 @@ describe Projects::MergeRequestsController do
end
end
context
'number of queries'
do
context
'number of queries'
,
:request_store
do
it
'verifies number of queries'
do
RequestStore
.
begin!
# pre-create objects
merge_request
...
...
@@ -130,9 +128,6 @@ describe Projects::MergeRequestsController do
expect
(
recorded
.
count
).
to
be_within
(
5
).
of
(
30
)
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
RequestStore
.
end!
RequestStore
.
clear!
end
end
end
...
...
spec/controllers/projects/pipelines_controller_spec.rb
View file @
34ba8039
...
...
@@ -49,21 +49,14 @@ describe Projects::PipelinesController do
expect
(
json_response
[
'details'
]).
to
have_key
'stages'
end
context
'when the pipeline has multiple stages and groups'
do
context
'when the pipeline has multiple stages and groups'
,
:request_store
do
before
do
RequestStore
.
begin!
create_build
(
'build'
,
0
,
'build'
)
create_build
(
'test'
,
1
,
'rspec 0'
)
create_build
(
'deploy'
,
2
,
'production'
)
create_build
(
'post deploy'
,
3
,
'pages 0'
)
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
let
(
:project
)
{
create
(
:project
)
}
let
(
:pipeline
)
do
create
(
:ci_empty_pipeline
,
project:
project
,
user:
user
,
sha:
project
.
commit
.
id
)
...
...
spec/lib/banzai/filter/abstract_reference_filter_spec.rb
View file @
34ba8039
...
...
@@ -47,16 +47,7 @@ describe Banzai::Filter::AbstractReferenceFilter do
end
end
context
'with RequestStore enabled'
do
before
do
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
context
'with RequestStore enabled'
,
:request_store
do
it
'returns a list of Projects for a list of paths'
do
expect
(
filter
.
find_projects_for_paths
([
project
.
path_with_namespace
])).
to
eq
([
project
])
...
...
spec/lib/banzai/issuable_extractor_spec.rb
View file @
34ba8039
...
...
@@ -29,16 +29,7 @@ describe Banzai::IssuableExtractor, lib: true do
expect
(
result
).
to
eq
(
issue_link
=>
issue
,
merge_request_link
=>
merge_request
)
end
describe
'caching'
do
before
do
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
describe
'caching'
,
:request_store
do
it
'saves records to cache'
do
extractor
.
extract
([
issue_link
,
merge_request_link
])
...
...
spec/lib/banzai/reference_parser/user_parser_spec.rb
View file @
34ba8039
...
...
@@ -43,18 +43,9 @@ describe Banzai::ReferenceParser::UserParser, lib: true do
expect
(
subject
.
referenced_by
([
link
])).
to
eq
([
user
])
end
context
'when RequestStore is active'
do
context
'when RequestStore is active'
,
:request_store
do
let
(
:other_user
)
{
create
(
:user
)
}
before
do
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
it
'does not return users from the first call in the second'
do
link
[
'data-user'
]
=
user
.
id
.
to_s
...
...
spec/models/concerns/routable_spec.rb
View file @
34ba8039
...
...
@@ -122,16 +122,7 @@ describe Group, 'Routable' do
it
{
expect
(
group
.
full_path
).
to
eq
(
group
.
path
)
}
it
{
expect
(
nested_group
.
full_path
).
to
eq
(
"
#{
group
.
full_path
}
/
#{
nested_group
.
path
}
"
)
}
context
'with RequestStore active'
do
before
do
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
context
'with RequestStore active'
,
:request_store
do
it
'does not load the route table more than once'
do
expect
(
group
).
to
receive
(
:uncached_full_path
).
once
.
and_call_original
...
...
spec/models/project_team_spec.rb
View file @
34ba8039
...
...
@@ -389,16 +389,7 @@ describe ProjectTeam, models: true do
end
describe
'#max_member_access_for_user_ids'
do
context
'with RequestStore enabled'
do
before
do
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
context
'with RequestStore enabled'
,
:request_store
do
include_examples
'max member access for users'
def
access_levels
(
users
)
...
...
spec/serializers/pipeline_serializer_spec.rb
View file @
34ba8039
...
...
@@ -102,18 +102,11 @@ describe PipelineSerializer do
Ci
::
Pipeline
::
AVAILABLE_STATUSES
.
each
do
|
status
|
create_pipeline
(
status
)
end
RequestStore
.
begin!
end
after
do
RequestStore
.
end!
RequestStore
.
clear!
end
it
"verifies number of queries"
do
it
'verifies number of queries'
,
:request_store
do
recorded
=
ActiveRecord
::
QueryRecorder
.
new
{
subject
}
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
60
)
expect
(
recorded
.
count
).
to
be_within
(
1
).
of
(
57
)
expect
(
recorded
.
cached_count
).
to
eq
(
0
)
end
...
...
spec/spec_helper.rb
View file @
34ba8039
...
...
@@ -74,6 +74,15 @@ RSpec.configure do |config|
TestEnv
.
cleanup
end
config
.
before
(
:example
,
:request_store
)
do
RequestStore
.
begin!
end
config
.
after
(
:example
,
:request_store
)
do
RequestStore
.
end!
RequestStore
.
clear!
end
if
ENV
[
'CI'
]
# Retry only on feature specs that use JS
config
.
around
:each
,
:js
do
|
ex
|
...
...
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