summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-12-16 20:12:59 +0800
committerClement Ho <ClemMakesApps@gmail.com>2017-01-09 16:01:35 -0600
commit464dddf4d0b54085c10ecb8b62aa7816ed7ba8a3 (patch)
treeed65e458e90dff55222c58d5f16b814caa4e02b7
parent866bb202f29b8f5ad52563dd48ae57168dc6df77 (diff)
downloadgitlab-ce-464dddf4d0b54085c10ecb8b62aa7816ed7ba8a3.tar.gz
Show no issues if author/assignee cannot be found
Feedback: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7345/diffs#note_19994225
-rw-r--r--app/finders/issuable_finder.rb20
1 files changed, 12 insertions, 8 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb
index dfd7de6afa9..dce756544e7 100644
--- a/app/finders/issuable_finder.rb
+++ b/app/finders/issuable_finder.rb
@@ -178,7 +178,7 @@ class IssuableFinder
@assignee =
if assignee_id?
- User.find(params[:assignee_id])
+ User.find_by(id: params[:assignee_id])
elsif assignee_username?
User.find_by(username: params[:assignee_username])
else
@@ -198,9 +198,9 @@ class IssuableFinder
return @author if defined?(@author)
@author =
- if author_id? && params[:author_id] != NONE
- User.find(params[:author_id])
- elsif author_username? && params[:author_username] != NONE
+ if author_id?
+ User.find_by(id: params[:author_id])
+ elsif author_username?
User.find_by(username: params[:author_username])
else
nil
@@ -275,16 +275,20 @@ class IssuableFinder
end
def by_assignee(items)
- if assignee_id? || assignee_username?
- items = items.where(assignee_id: assignee.try(:id))
+ if assignee
+ items = items.where(assignee_id: assignee.id)
+ elsif assignee_id? || assignee_username? # assignee not found
+ items = items.none
end
items
end
def by_author(items)
- if author_id? || author_username?
- items = items.where(author_id: author.try(:id))
+ if author
+ items = items.where(author_id: author.id)
+ elsif author_id? || author_username? # author not found
+ items = items.none
end
items