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
2fd03127
Commit
2fd03127
authored
Mar 22, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue assignees] Fix issuable.assignee_or_author?
parent
2f06d8b3
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
27 deletions
+50
-27
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-5
app/models/issue.rb
app/models/issue.rb
+4
-0
app/models/merge_request.rb
app/models/merge_request.rb
+4
-0
app/services/issues/export_csv_service.rb
app/services/issues/export_csv_service.rb
+1
-1
spec/models/concerns/issuable_spec.rb
spec/models/concerns/issuable_spec.rb
+0
-21
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+21
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+20
-0
No files found.
app/models/concerns/issuable.rb
View file @
2fd03127
...
...
@@ -342,11 +342,6 @@ module Issuable
false
end
def
assignee_or_author?
(
user
)
# We're comparing IDs here so we don't need to load any associations.
author_id
==
user
.
id
||
assignee_id
==
user
.
id
end
def
record_metrics
metrics
=
self
.
metrics
||
create_metrics
metrics
.
record!
...
...
app/models/issue.rb
View file @
2fd03127
...
...
@@ -139,6 +139,10 @@ class Issue < ActiveRecord::Base
}
end
def
assignee_or_author?
(
user
)
author_id
==
user
.
id
||
assignees
.
exists?
(
user
)
end
def
assignee_list
assignees
.
pluck
(
:name
).
join
(
', '
)
end
...
...
app/models/merge_request.rb
View file @
2fd03127
...
...
@@ -193,6 +193,10 @@ class MergeRequest < ActiveRecord::Base
}
end
def
assignee_or_author?
(
user
)
author_id
==
user
.
id
||
assignee_id
==
user
.
id
end
# `from` argument can be a Namespace or Project.
def
to_reference
(
from
=
nil
,
full:
false
)
reference
=
"
#{
self
.
class
.
reference_prefix
}#{
iid
}
"
...
...
app/services/issues/export_csv_service.rb
View file @
2fd03127
...
...
@@ -36,7 +36,7 @@ module Issues
'Author'
=>
'author_name'
,
'Author Username'
=>
->
(
issue
)
{
issue
.
author
&
.
username
},
'Assignee'
=>
'assignee_name'
,
'Assignee Username'
=>
->
(
issue
)
{
issue
.
assignee
&
.
username
},
'Assignee Username'
=>
->
(
issue
)
{
issue
.
assignee
_list
},
'Confidential'
=>
->
(
issue
)
{
issue
.
confidential?
?
'Yes'
:
'No'
},
'Due Date'
=>
->
(
issue
)
{
issue
.
due_date
&
.
to_s
(
:csv
)
},
'Created At (UTC)'
=>
->
(
issue
)
{
issue
.
created_at
&
.
to_s
(
:csv
)
},
...
...
spec/models/concerns/issuable_spec.rb
View file @
2fd03127
...
...
@@ -493,27 +493,6 @@ describe Issue, "Issuable" do
end
end
describe
'#assignee_or_author?'
do
let
(
:user
)
{
build
(
:user
,
id:
1
)
}
let
(
:issue
)
{
build
(
:issue
)
}
it
'returns true for a user that is assigned to an issue'
do
issue
.
assignee
=
user
expect
(
issue
.
assignee_or_author?
(
user
)).
to
eq
(
true
)
end
it
'returns true for a user that is the author of an issue'
do
issue
.
author
=
user
expect
(
issue
.
assignee_or_author?
(
user
)).
to
eq
(
true
)
end
it
'returns false for a user that is not the assignee or author'
do
expect
(
issue
.
assignee_or_author?
(
user
)).
to
eq
(
false
)
end
end
describe
'#spend_time'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
)
}
...
...
spec/models/issue_spec.rb
View file @
2fd03127
...
...
@@ -132,6 +132,27 @@ describe Issue, models: true do
end
end
describe
'#assignee_or_author?'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:issue
)
{
create
(
:issue
)
}
it
'returns true for a user that is assigned to an issue'
do
issue
.
assignees
<<
user
expect
(
issue
.
assignee_or_author?
(
user
)).
to
be_truthy
end
it
'returns true for a user that is the author of an issue'
do
issue
.
update
(
author:
user
)
expect
(
issue
.
assignee_or_author?
(
user
)).
to
be_truthy
end
it
'returns false for a user that is not the assignee or author'
do
expect
(
issue
.
assignee_or_author?
(
user
)).
to
be_falsey
end
end
describe
'#is_being_reassigned?'
do
it
'returns true if the issue assignee has changed'
do
subject
.
assignee
=
create
(
:user
)
...
...
spec/models/merge_request_spec.rb
View file @
2fd03127
...
...
@@ -87,6 +87,26 @@ describe MergeRequest, models: true do
end
end
describe
'#assignee_or_author?'
do
let
(
:user
)
{
build
(
:user
)
}
it
'returns true for a user that is assigned to a merge request'
do
subject
.
assignee
=
user
expect
(
subject
.
assignee_or_author?
(
user
)).
to
eq
(
true
)
end
it
'returns true for a user that is the author of a merge request'
do
subject
.
author
=
user
expect
(
subject
.
assignee_or_author?
(
user
)).
to
eq
(
true
)
end
it
'returns false for a user that is not the assignee or author'
do
expect
(
subject
.
assignee_or_author?
(
user
)).
to
eq
(
false
)
end
end
describe
'#cache_merge_request_closes_issues!'
do
before
do
subject
.
project
.
team
<<
[
subject
.
author
,
:developer
]
...
...
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