summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-10 15:04:52 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-02-10 15:04:52 +0200
commit56f989e53e80fe7545a3400ba7ee98a0cd2cf259 (patch)
treee43d7b724b373969ce0dfa9a59c1c447352f8d95
parent5a098e84e4de30d95ba5e0a3a7bbd81813cf3305 (diff)
downloadgitlab-ce-56f989e53e80fe7545a3400ba7ee98a0cd2cf259.tar.gz
Fix wrong issues appears at Dashboard#issues page
Filtering service used klass instead of passed items. Because of this you see list of all issues intead of authorized ones. This commit fixes it so people see only issues they are authorized to see. Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/controllers/dashboard_controller.rb4
-rw-r--r--app/models/concerns/issuable.rb10
-rw-r--r--app/services/filtering_service.rb6
3 files changed, 10 insertions, 10 deletions
diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb
index 656eda9dec2..b95233c0e91 100644
--- a/app/controllers/dashboard_controller.rb
+++ b/app/controllers/dashboard_controller.rb
@@ -54,12 +54,12 @@ class DashboardController < ApplicationController
def merge_requests
@merge_requests = FilteringService.new.execute(MergeRequest, current_user, params)
- @merge_requests = @merge_requests.recent.page(params[:page]).per(20)
+ @merge_requests = @merge_requests.page(params[:page]).per(20)
end
def issues
@issues = FilteringService.new.execute(Issue, current_user, params)
- @issues = @issues.recent.page(params[:page]).per(20)
+ @issues = @issues.page(params[:page]).per(20)
@issues = @issues.includes(:author, :project)
respond_to do |format|
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb
index 0f1dad4ef16..bf2c2157d38 100644
--- a/app/models/concerns/issuable.rb
+++ b/app/models/concerns/issuable.rb
@@ -48,13 +48,13 @@ module Issuable
def sort(method)
case method.to_s
- when 'newest' then reorder('created_at DESC')
- when 'oldest' then reorder('created_at ASC')
- when 'recently_updated' then reorder('updated_at DESC')
- when 'last_updated' then reorder('updated_at ASC')
+ when 'newest' then reorder("#{table_name}.created_at DESC")
+ when 'oldest' then reorder("#{table_name}.created_at ASC")
+ when 'recently_updated' then reorder("#{table_name}.updated_at DESC")
+ when 'last_updated' then reorder("#{table_name}.updated_at ASC")
when 'milestone_due_soon' then joins(:milestone).reorder("milestones.due_date ASC")
when 'milestone_due_later' then joins(:milestone).reorder("milestones.due_date DESC")
- else reorder('created_at DESC')
+ else reorder("#{table_name}.created_at DESC")
end
end
end
diff --git a/app/services/filtering_service.rb b/app/services/filtering_service.rb
index ebd394ee758..52537f7ba4f 100644
--- a/app/services/filtering_service.rb
+++ b/app/services/filtering_service.rb
@@ -57,11 +57,11 @@ class FilteringService
def by_scope(items)
case params[:scope]
when 'created-by-me', 'authored' then
- klass.where(author_id: current_user.id)
+ items.where(author_id: current_user.id)
when 'all' then
- klass
+ items
when 'assigned-to-me' then
- klass.where(assignee_id: current_user.id)
+ items.where(assignee_id: current_user.id)
else
raise 'You must specify default scope'
end