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
Léo-Paul Géneau
gitlab-ce
Commits
b8331414
Commit
b8331414
authored
Oct 06, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add latest changes from gitlab-org/gitlab@master
parent
7b871b34
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
22 deletions
+15
-22
app/models/repository.rb
app/models/repository.rb
+1
-1
changelogs/unreleased/cache-issues-with-has_visible_content.yml
...logs/unreleased/cache-issues-with-has_visible_content.yml
+5
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+9
-21
No files found.
app/models/repository.rb
View file @
b8331414
...
...
@@ -568,7 +568,7 @@ class Repository
delegate
:branch_count
,
:tag_count
,
:has_visible_content?
,
to: :raw_repository
cache_method
:branch_count
,
fallback:
0
cache_method
:tag_count
,
fallback:
0
cache_method
:has_visible_content?
,
fallback:
false
cache_method
_asymmetrically
:has_visible_content?
def
avatar
# n+1: https://gitlab.com/gitlab-org/gitlab-foss/issues/38327
...
...
changelogs/unreleased/cache-issues-with-has_visible_content.yml
0 → 100644
View file @
b8331414
---
title
:
Use cache_method_asymmetrically with Repository#has_visible_content?
merge_request
:
17975
author
:
type
:
fixed
spec/models/repository_spec.rb
View file @
b8331414
...
...
@@ -1193,33 +1193,21 @@ describe Repository do
end
describe
'#has_visible_content?'
do
before
do
# If raw_repository.has_visible_content? gets called more than once then
# caching is broken. We don't want that.
it
'delegates to raw_repository when true'
do
expect
(
repository
.
raw_repository
).
to
receive
(
:has_visible_content?
)
.
once
.
and_return
(
result
)
end
context
'when true'
do
let
(
:result
)
{
true
}
.
and_return
(
true
)
it
'returns true and caches it'
do
expect
(
repository
.
has_visible_content?
).
to
eq
(
true
)
# Second call hits the cache
expect
(
repository
.
has_visible_content?
).
to
eq
(
true
)
end
expect
(
repository
.
has_visible_content?
).
to
eq
(
true
)
end
context
'when false'
do
let
(
:result
)
{
false
}
it
'delegates to raw_repository when false'
do
expect
(
repository
.
raw_repository
).
to
receive
(
:has_visible_content?
)
.
and_return
(
false
)
it
'returns false and caches it'
do
expect
(
repository
.
has_visible_content?
).
to
eq
(
false
)
# Second call hits the cache
expect
(
repository
.
has_visible_content?
).
to
eq
(
false
)
end
expect
(
repository
.
has_visible_content?
).
to
eq
(
false
)
end
it_behaves_like
'asymmetric cached method'
,
:has_visible_content?
end
describe
'#branch_exists?'
do
...
...
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