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
01e1c664
Commit
01e1c664
authored
Apr 03, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue asignees] fix update_cache_counts for issues and specs for that[ci skip]
parent
01d38b02
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
18 deletions
+56
-18
app/models/issue.rb
app/models/issue.rb
+0
-8
app/models/issue_assignee.rb
app/models/issue_assignee.rb
+9
-2
app/models/merge_request.rb
app/models/merge_request.rb
+1
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+46
-7
No files found.
app/models/issue.rb
View file @
01e1c664
...
...
@@ -136,14 +136,6 @@ class Issue < ActiveRecord::Base
"id DESC"
)
end
def
update_assignee_cache_counts
return
true
# TODO implement it properly
# make sure we flush the cache for both the old *and* new assignees(if they exist)
previous_assignee
=
User
.
find_by_id
(
assignee_id_was
)
if
assignee_id_was
previous_assignee
&
.
update_cache_counts
assignee
&
.
update_cache_counts
end
# Returns a Hash of attributes to be used for Twitter card metadata
def
card_attributes
{
...
...
app/models/issue_assignee.rb
View file @
01e1c664
class
IssueAssignee
<
ActiveRecord
::
Base
belongs_to
:issue
belongs_to
:assignee
,
class_name:
"User"
,
foreign_key: :user_id
after_create
:update_assignee_cache_counts
after_destroy
:update_assignee_cache_counts
def
update_assignee_cache_counts
assignee
&
.
update_cache_counts
end
end
app/models/merge_request.rb
View file @
01e1c664
...
...
@@ -210,7 +210,7 @@ class MergeRequest < ActiveRecord::Base
# This method is needed for compatibility with issues to not mess view and other code
def
assignees
assignee
?
[
assignee
]
:
[]
Array
(
assignee
)
end
def
assignee_or_author?
(
user
)
...
...
spec/models/concerns/issuable_spec.rb
View file @
01e1c664
...
...
@@ -58,12 +58,12 @@ describe Issue, "Issuable" do
end
describe
"before_save"
do
describe
"#update_cache_counts"
do
describe
"#update_cache_counts
when an issue is reassigned
"
do
context
"when previous assignee exists"
do
before
do
assignee
=
create
(
:user
)
issue
.
project
.
team
<<
[
assignee
,
:developer
]
issue
.
update
(
assignee:
assignee
)
issue
.
assignees
<<
assignee
end
it
"updates cache counts for new assignee"
do
...
...
@@ -71,26 +71,65 @@ describe Issue, "Issuable" do
expect
(
user
).
to
receive
(
:update_cache_counts
)
issue
.
update
(
assignee:
user
)
issue
.
assignees
<<
user
end
it
"updates cache counts for previous assignee"
do
old_assignee
=
issue
.
assignee
old_assignee
=
issue
.
assignees
.
first
expect_any_instance_of
(
User
).
to
receive
(
:update_cache_counts
)
issue
.
assignees
.
destroy_all
end
end
context
"when previous assignee does not exist"
do
before
{
issue
.
assignees
=
[]
}
it
"updates cache count for the new assignee"
do
expect_any_instance_of
(
User
).
to
receive
(
:update_cache_counts
)
issue
.
assignees
<<
user
end
end
end
describe
"#update_cache_counts when a merge request is reassigned"
do
let
(
:project
)
{
create
:project
}
let
(
:merge_request
)
{
create
(
:merge_request
,
source_project:
project
,
target_project:
project
)
}
context
"when previous assignee exists"
do
before
do
assignee
=
create
(
:user
)
project
.
team
<<
[
assignee
,
:developer
]
merge_request
.
update
(
assignee:
assignee
)
end
it
"updates cache counts for new assignee"
do
user
=
create
(
:user
)
expect
(
user
).
to
receive
(
:update_cache_counts
)
merge_request
.
update
(
assignee:
user
)
end
it
"updates cache counts for previous assignee"
do
old_assignee
=
merge_request
.
assignee
allow
(
User
).
to
receive
(
:find_by_id
).
with
(
old_assignee
.
id
).
and_return
(
old_assignee
)
expect
(
old_assignee
).
to
receive
(
:update_cache_counts
)
issue
.
update
(
assignee:
nil
)
merge_request
.
update
(
assignee:
nil
)
end
end
context
"when previous assignee does not exist"
do
before
{
issue
.
update
(
assignee:
nil
)
}
before
{
merge_request
.
update
(
assignee:
nil
)
}
it
"updates cache count for the new assignee"
do
expect_any_instance_of
(
User
).
to
receive
(
:update_cache_counts
)
issue
.
update
(
assignee:
user
)
merge_request
.
update
(
assignee:
user
)
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