Commit 56f989e5 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

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: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 5a098e84
......@@ -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|
......
......@@ -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
......
......@@ -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
......
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