BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
8835b788
Commit
8835b788
authored
Jun 01, 2016
by
Josh Frye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flush cache in callback. Add tests
parent
bfccea37
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
4 deletions
+32
-4
issuable.rb
app/models/concerns/issuable.rb
+8
-0
user.rb
app/models/user.rb
+9
-4
issues_spec.rb
spec/features/issues_spec.rb
+15
-0
No files found.
app/models/concerns/issuable.rb
View file @
8835b788
...
...
@@ -68,6 +68,14 @@ module Issuable
strip_attributes
:title
acts_as_paranoid
after_save
:update_assignee_cache_counts
,
if: :assignee_id_changed?
def
update_assignee_cache_counts
# make sure we flush the cache for both the old *and* new assignee
User
.
find
(
assignee_id_was
).
update_cache_counts
if
assignee_id_was
assignee
.
update_cache_counts
if
assignee_id
end
end
module
ClassMethods
...
...
app/models/user.rb
View file @
8835b788
...
...
@@ -776,18 +776,23 @@ class User < ActiveRecord::Base
notification_settings
.
find_or_initialize_by
(
source:
source
)
end
def
assigned_open_merge_request_count
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_merge_request_count'
],
expires_in:
60
)
do
def
assigned_open_merge_request_count
(
force:
false
)
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_merge_request_count'
],
force:
force
)
do
assigned_merge_requests
.
opened
.
count
end
end
def
assigned_open_issues_count
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_issues_count'
],
expires_in:
60
)
do
def
assigned_open_issues_count
(
force:
false
)
Rails
.
cache
.
fetch
([
'users'
,
id
,
'assigned_open_issues_count'
],
force:
force
)
do
assigned_issues
.
opened
.
count
end
end
def
update_cache_counts
assigned_open_merge_request_count
(
force:
true
)
assigned_open_issues_count
(
force:
true
)
end
private
def
projects_union
...
...
spec/features/issues_spec.rb
View file @
8835b788
...
...
@@ -62,6 +62,21 @@ describe 'Issues', feature: true do
expect
(
issue
.
reload
.
assignee
).
to
be_nil
end
it
'updates assigned cache count on change'
,
js:
true
do
visit
edit_namespace_project_issue_path
(
project
.
namespace
,
project
,
issue
)
expect
(
page
).
to
have_content
"Assignee
#{
@user
.
name
}
"
expect
(
@user
.
assigned_open_issues_count
).
to
eq
@user
.
assigned_issues
.
opened
.
count
first
(
'#s2id_issue_assignee_id'
).
click
sleep
2
# wait for ajax stuff to complete
first
(
'.user-result'
).
click
click_button
'Save changes'
expect
(
@user
.
assigned_open_issues_count
).
to
eq
@user
.
assigned_issues
.
opened
.
count
end
end
describe
'due date'
,
js:
true
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