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
46476acf
Commit
46476acf
authored
Apr 28, 2021
by
Tetiana Chupryna
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
User proper stubs for testing
parent
e13ab34a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
10 deletions
+4
-10
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+4
-10
No files found.
spec/models/namespace_spec.rb
View file @
46476acf
...
...
@@ -239,28 +239,22 @@ RSpec.describe Namespace do
create
(
:project
,
namespace:
namespace
,
container_repositories:
repositories
)
stub_container_registry_config
(
enabled:
true
)
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
])
end
it
'finds tags'
do
allow_next_found_instance_of
(
ContainerRepository
)
do
|
repository
|
allow
(
repository
).
to
receive
(
:has_tags?
).
and_return
(
true
)
end
stub_container_registry_tags
(
repository: :any
,
tags:
[
'tag'
])
is_expected
.
to
be_truthy
end
it
'does not cause N+1 query'
do
allow_next_found_instance_of
(
ContainerRepository
)
do
|
repository
|
allow
(
repository
).
to
receive
(
:has_tags?
).
and_return
(
false
)
end
it
'does not cause N+1 query in fetching registries'
do
stub_container_registry_tags
(
repository: :any
,
tags:
[])
control_count
=
ActiveRecord
::
QueryRecorder
.
new
{
namespace
.
any_project_has_container_registry_tags?
}.
count
other_repositories
=
create_list
(
:container_repository
,
2
)
create
(
:project
,
namespace:
namespace
,
container_repositories:
other_repositories
)
expect
{
namespace
.
any_project_has_container_registry_tags?
}.
not_to
exceed_query_limit
(
control_count
)
expect
{
namespace
.
any_project_has_container_registry_tags?
}.
not_to
exceed_query_limit
(
control_count
+
1
)
end
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