Commit 464dddf4 authored by Lin Jen-Shin's avatar Lin Jen-Shin Committed by Clement Ho

Show no issues if author/assignee cannot be found

Feedback:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7345/diffs#note_19994225
parent 866bb202
...@@ -178,7 +178,7 @@ class IssuableFinder ...@@ -178,7 +178,7 @@ class IssuableFinder
@assignee = @assignee =
if assignee_id? if assignee_id?
User.find(params[:assignee_id]) User.find_by(id: params[:assignee_id])
elsif assignee_username? elsif assignee_username?
User.find_by(username: params[:assignee_username]) User.find_by(username: params[:assignee_username])
else else
...@@ -198,9 +198,9 @@ class IssuableFinder ...@@ -198,9 +198,9 @@ class IssuableFinder
return @author if defined?(@author) return @author if defined?(@author)
@author = @author =
if author_id? && params[:author_id] != NONE if author_id?
User.find(params[:author_id]) User.find_by(id: params[:author_id])
elsif author_username? && params[:author_username] != NONE elsif author_username?
User.find_by(username: params[:author_username]) User.find_by(username: params[:author_username])
else else
nil nil
...@@ -275,16 +275,20 @@ class IssuableFinder ...@@ -275,16 +275,20 @@ class IssuableFinder
end end
def by_assignee(items) def by_assignee(items)
if assignee_id? || assignee_username? if assignee
items = items.where(assignee_id: assignee.try(:id)) items = items.where(assignee_id: assignee.id)
elsif assignee_id? || assignee_username? # assignee not found
items = items.none
end end
items items
end end
def by_author(items) def by_author(items)
if author_id? || author_username? if author
items = items.where(author_id: author.try(:id)) items = items.where(author_id: author.id)
elsif author_id? || author_username? # author not found
items = items.none
end end
items items
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment