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
Boxiang Sun
gitlab-ce
Commits
33687db0
Commit
33687db0
authored
May 26, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix counters cache invalidation for Issues and Merge Requests
parent
0d65fd03
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
44 additions
and
0 deletions
+44
-0
app/services/issues/close_service.rb
app/services/issues/close_service.rb
+1
-0
app/services/issues/reopen_service.rb
app/services/issues/reopen_service.rb
+1
-0
app/services/merge_requests/close_service.rb
app/services/merge_requests/close_service.rb
+1
-0
app/services/merge_requests/post_merge_service.rb
app/services/merge_requests/post_merge_service.rb
+1
-0
app/services/merge_requests/reopen_service.rb
app/services/merge_requests/reopen_service.rb
+1
-0
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+6
-0
spec/services/issues/reopen_service_spec.rb
spec/services/issues/reopen_service_spec.rb
+7
-0
spec/services/merge_requests/close_service_spec.rb
spec/services/merge_requests/close_service_spec.rb
+2
-0
spec/services/merge_requests/post_merge_service_spec.rb
spec/services/merge_requests/post_merge_service_spec.rb
+15
-0
spec/services/merge_requests/reopen_service_spec.rb
spec/services/merge_requests/reopen_service_spec.rb
+2
-0
spec/support/issuable_shared_examples.rb
spec/support/issuable_shared_examples.rb
+7
-0
No files found.
app/services/issues/close_service.rb
View file @
33687db0
...
...
@@ -28,6 +28,7 @@ module Issues
notification_service
.
close_issue
(
issue
,
current_user
)
if
notifications
todo_service
.
close_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'close'
)
invalidate_cache_counts
(
issue
.
assignees
,
issue
)
end
issue
...
...
app/services/issues/reopen_service.rb
View file @
33687db0
...
...
@@ -8,6 +8,7 @@ module Issues
create_note
(
issue
)
notification_service
.
reopen_issue
(
issue
,
current_user
)
execute_hooks
(
issue
,
'reopen'
)
invalidate_cache_counts
(
issue
.
assignees
,
issue
)
end
issue
...
...
app/services/merge_requests/close_service.rb
View file @
33687db0
...
...
@@ -13,6 +13,7 @@ module MergeRequests
notification_service
.
close_mr
(
merge_request
,
current_user
)
todo_service
.
close_merge_request
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'close'
)
invalidate_cache_counts
(
merge_request
.
assignees
,
merge_request
)
end
merge_request
...
...
app/services/merge_requests/post_merge_service.rb
View file @
33687db0
...
...
@@ -13,6 +13,7 @@ module MergeRequests
create_note
(
merge_request
)
notification_service
.
merge_mr
(
merge_request
,
current_user
)
execute_hooks
(
merge_request
,
'merge'
)
invalidate_cache_counts
(
merge_request
.
assignees
,
merge_request
)
end
private
...
...
app/services/merge_requests/reopen_service.rb
View file @
33687db0
...
...
@@ -10,6 +10,7 @@ module MergeRequests
execute_hooks
(
merge_request
,
'reopen'
)
merge_request
.
reload_diff
(
current_user
)
merge_request
.
mark_as_unchecked
invalidate_cache_counts
(
merge_request
.
assignees
,
merge_request
)
end
merge_request
...
...
spec/services/issues/close_service_spec.rb
View file @
33687db0
...
...
@@ -41,6 +41,12 @@ describe Issues::CloseService, services: true do
service
.
execute
(
issue
)
end
it
'invalidates counter cache for assignees'
do
expect_any_instance_of
(
User
).
to
receive
(
:invalidate_issue_cache_counts
)
service
.
execute
(
issue
)
end
end
describe
'#close_issue'
do
...
...
spec/services/issues/reopen_service_spec.rb
View file @
33687db0
...
...
@@ -27,6 +27,13 @@ describe Issues::ReopenService, services: true do
project
.
team
<<
[
user
,
:master
]
end
it
'invalidates counter cache for assignees'
do
issue
.
assignees
<<
user
expect_any_instance_of
(
User
).
to
receive
(
:invalidate_issue_cache_counts
)
described_class
.
new
(
project
,
user
).
execute
(
issue
)
end
context
'when issue is not confidential'
do
it
'executes issue hooks'
do
expect
(
project
).
to
receive
(
:execute_hooks
).
with
(
an_instance_of
(
Hash
),
:issue_hooks
)
...
...
spec/services/merge_requests/close_service_spec.rb
View file @
33687db0
...
...
@@ -15,6 +15,8 @@ describe MergeRequests::CloseService, services: true do
end
describe
'#execute'
do
it_behaves_like
'cache counters invalidator'
context
'valid params'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
{})
}
...
...
spec/services/merge_requests/post_merge_service_spec.rb
0 → 100644
View file @
33687db0
require
'spec_helper'
describe
MergeRequests
::
PostMergeService
,
services:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
assignee:
user
)
}
let
(
:project
)
{
merge_request
.
project
}
before
do
project
.
team
<<
[
user
,
:master
]
end
describe
'#execute'
do
it_behaves_like
'cache counters invalidator'
end
end
spec/services/merge_requests/reopen_service_spec.rb
View file @
33687db0
...
...
@@ -14,6 +14,8 @@ describe MergeRequests::ReopenService, services: true do
end
describe
'#execute'
do
it_behaves_like
'cache counters invalidator'
context
'valid params'
do
let
(
:service
)
{
described_class
.
new
(
project
,
user
,
{})
}
...
...
spec/support/issuable_shared_examples.rb
0 → 100644
View file @
33687db0
shared_examples
'cache counters invalidator'
do
it
'invalidates counter cache for assignees'
do
expect_any_instance_of
(
User
).
to
receive
(
:invalidate_merge_request_cache_counts
)
described_class
.
new
(
project
,
user
,
{}).
execute
(
merge_request
)
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