diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-27 04:56:42 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-03-27 04:56:42 +0300 |
commit | dfb4fcb68544717d5cc74a2035a9d9c5bd61fc21 (patch) | |
tree | 66ade537268e685ea6fc71a45d8d03e2d33bc13f /app | |
parent | 090f2344ecb6631b20df5853045536f1eb0589d3 (diff) |
No magic numbers for issues filtering
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/issuable_finder.rb | 8 | ||||
-rw-r--r-- | app/services/issues/update_service.rb | 4 | ||||
-rw-r--r-- | app/services/merge_requests/update_service.rb | 4 |
3 files changed, 9 insertions, 7 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 088a766ed3a..67939c094c5 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -19,6 +19,8 @@ require_relative 'projects_finder' class IssuableFinder + NONE = 0 + attr_accessor :current_user, :params def execute(current_user, params) @@ -112,7 +114,7 @@ class IssuableFinder def by_milestone(items) if params[:milestone_id].present? - items = items.where(milestone_id: (params[:milestone_id] == '0' ? nil : params[:milestone_id])) + items = items.where(milestone_id: (params[:milestone_id] == NONE ? nil : params[:milestone_id])) end items @@ -120,7 +122,7 @@ class IssuableFinder def by_assignee(items) if params[:assignee_id].present? - items = items.where(assignee_id: (params[:assignee_id] == '0' ? nil : params[:assignee_id])) + items = items.where(assignee_id: (params[:assignee_id] == NONE ? nil : params[:assignee_id])) end items @@ -128,7 +130,7 @@ class IssuableFinder def by_author(items) if params[:author_id].present? - items = items.where(author_id: (params[:author_id] == '0' ? nil : params[:author_id])) + items = items.where(author_id: (params[:author_id] == NONE ? nil : params[:author_id])) end items diff --git a/app/services/issues/update_service.rb b/app/services/issues/update_service.rb index 3371fe7d5ef..8f04a69287a 100644 --- a/app/services/issues/update_service.rb +++ b/app/services/issues/update_service.rb @@ -14,8 +14,8 @@ module Issues issue.update_nth_task(params[:task_num].to_i, false) end - params[:assignee_id] = "" if params[:assignee_id] == "-1" - params[:milestone_id] = "" if params[:milestone_id] == "-1" + params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE + params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE old_labels = issue.labels.to_a diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 0ac6dfea6fd..23af2656c37 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -23,8 +23,8 @@ module MergeRequests merge_request.update_nth_task(params[:task_num].to_i, false) end - params[:assignee_id] = "" if params[:assignee_id] == "-1" - params[:milestone_id] = "" if params[:milestone_id] == "-1" + params[:assignee_id] = "" if params[:assignee_id] == IssuableFinder::NONE + params[:milestone_id] = "" if params[:milestone_id] == IssuableFinder::NONE old_labels = merge_request.labels.to_a |