Fix filtering issues by "No Label"

This commit is contained in:
Douglas Barbosa Alexandre 2016-08-09 16:09:30 -03:00
parent 5490a9fe83
commit 1b7f137e95
2 changed files with 10 additions and 10 deletions

View File

@ -3,7 +3,8 @@ module Boards
class ListService < Boards::BaseService
def execute
issues = IssuesFinder.new(user, filter_params).execute
issues = without_board_labels(issues) if list.backlog?
issues = without_board_labels(issues) unless list.label?
issues = with_list_label(issues) if list.label?
issues
end
@ -16,7 +17,6 @@ module Boards
def filter_params
set_default_scope
set_default_sort
set_list_label
set_project
set_state
@ -31,13 +31,6 @@ module Boards
params[:sort] = 'priority'
end
def set_list_label
return unless list.label?
params[:label_name] ||= []
params[:label_name] << list.label_name
end
def set_project
params[:project_id] = project.id
end
@ -58,6 +51,13 @@ module Boards
.where(label_id: board_label_ids).limit(1).arel.exists
)
end
def with_list_label(issues)
issues.where(
LabelLink.where("label_links.target_type = 'Issue' AND label_links.target_id = issues.id")
.where("label_links.label_id = ?", list.label_id).limit(1).arel.exists
)
end
end
end
end

View File

@ -39,7 +39,7 @@ describe Boards::Issues::ListService, services: true do
it 'delegates search to IssuesFinder' do
params = { id: list1.id }
expect_any_instance_of(IssuesFinder).to receive(:execute).once
expect_any_instance_of(IssuesFinder).to receive(:execute).once.and_call_original
described_class.new(project, user, params).execute
end