Commit 7919587e authored by Jan Provaznik's avatar Jan Provaznik Committed by charlie ablett

Fix all_list board param

When filtering board issues, EE version of the list_service can
add additional filters which were not covered in CE version of the
method.
parent fd4a3d64
......@@ -8,6 +8,8 @@ module EE
override :filter
def filter(issues)
return issues if params[:all_lists]
unless list&.movable? || list&.closed?
issues = without_assignees_from_lists(issues)
issues = without_milestones_from_lists(issues)
......
......@@ -4,46 +4,40 @@ require 'spec_helper'
RSpec.describe Boards::Issues::ListService, services: true do
describe '#execute' do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, :empty_repo, namespace: group) }
let(:project1) { create(:project, :empty_repo, namespace: group) }
let(:board) { create(:board, group: group) }
let(:m1) { create(:milestone, group: group) }
let(:m2) { create(:milestone, group: group) }
let(:bug) { create(:group_label, group: group, name: 'Bug') }
let(:development) { create(:group_label, group: group, name: 'Development') }
let(:testing) { create(:group_label, group: group, name: 'Testing') }
let(:p1) { create(:group_label, title: 'P1', group: group) }
let(:p2) { create(:group_label, title: 'P2', group: group) }
let(:p3) { create(:group_label, title: 'P3', group: group) }
let(:user_list) { create(:user_list, board: board, position: 2) }
let(:milestone) { create(:milestone, group: group) }
let(:milestone_list) { create(:milestone_list, board: board, position: 3, milestone: milestone) }
let(:backlog) { create(:backlog_list, board: board) }
let(:list1) { create(:list, board: board, label: development, position: 0) }
let(:list2) { create(:list, board: board, label: testing, position: 1) }
let(:closed) { create(:closed_list, board: board) }
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, weight: 9, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, weight: 1, title: 'Issue 2', labels: [p2]) }
let!(:opened_issue3) { create(:labeled_issue, project: project, milestone: m2, title: 'Assigned Issue', labels: [p3]) }
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Issue 3', closed_at: Time.current ) }
let(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) }
let(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
let(:list1_issue3) { create(:labeled_issue, project: project1, milestone: m1, labels: [development, p1]) }
let(:list2_issue1) { create(:labeled_issue, project: project1, milestone: m1, labels: [testing]) }
let(:closed_issue1) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
let(:closed_issue2) { create(:labeled_issue, :closed, project: project, labels: [p3]) }
let(:closed_issue3) { create(:issue, :closed, project: project1) }
let(:closed_issue4) { create(:labeled_issue, :closed, project: project1, labels: [p1]) }
let(:closed_issue5) { create(:labeled_issue, :closed, project: project1, labels: [development]) }
let_it_be(:user) { create(:user) }
let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :empty_repo, namespace: group) }
let_it_be(:project1) { create(:project, :empty_repo, namespace: group) }
let_it_be(:board, reload: true) { create(:board, group: group) }
let_it_be(:m1) { create(:milestone, group: group) }
let_it_be(:m2) { create(:milestone, group: group) }
let_it_be(:bug) { create(:group_label, group: group, name: 'Bug') }
let_it_be(:development) { create(:group_label, group: group, name: 'Development') }
let_it_be(:testing) { create(:group_label, group: group, name: 'Testing') }
let_it_be(:p1) { create(:group_label, title: 'P1', group: group) }
let_it_be(:p2) { create(:group_label, title: 'P2', group: group) }
let_it_be(:p3) { create(:group_label, title: 'P3', group: group) }
let_it_be(:milestone) { create(:milestone, group: group) }
let_it_be(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, weight: 9, title: 'Issue 1', labels: [bug]) }
let_it_be(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, weight: 1, title: 'Issue 2', labels: [p2]) }
let_it_be(:opened_issue3) { create(:labeled_issue, project: project, milestone: m2, title: 'Assigned Issue', labels: [p3]) }
let_it_be(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Issue 3', closed_at: Time.current ) }
let_it_be(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, development]) }
let_it_be(:list1_issue2) { create(:labeled_issue, project: project, milestone: m2, labels: [development]) }
let_it_be(:list1_issue3) { create(:labeled_issue, project: project1, milestone: m1, labels: [development, p1]) }
let_it_be(:list2_issue1) { create(:labeled_issue, project: project1, milestone: m1, labels: [testing]) }
let_it_be(:closed_issue1) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
let_it_be(:closed_issue2) { create(:labeled_issue, :closed, project: project, labels: [p3]) }
let_it_be(:closed_issue3) { create(:issue, :closed, project: project1, milestone: m1) }
let_it_be(:closed_issue4) { create(:labeled_issue, :closed, project: project1, labels: [p1]) }
let_it_be(:closed_issue5) { create(:labeled_issue, :closed, project: project1, labels: [development]) }
let(:parent) { group }
......@@ -54,6 +48,14 @@ RSpec.describe Boards::Issues::ListService, services: true do
opened_issue3.assignees.push(user_list.user)
end
context 'with assignee, milestone and label lists present' do
let!(:user_list) { create(:user_list, board: board, position: 2) }
let!(:milestone_list) { create(:milestone_list, board: board, position: 3, milestone: milestone) }
let!(:backlog) { create(:backlog_list, board: board) }
let!(:list1) { create(:list, board: board, label: development, position: 0) }
let!(:list2) { create(:list, board: board, label: testing, position: 1) }
let!(:closed) { create(:closed_list, board: board) }
context 'milestone lists' do
let!(:milestone_issue) { create(:labeled_issue, project: project, milestone: milestone_list.milestone, labels: [p3]) }
......@@ -149,6 +151,17 @@ RSpec.describe Boards::Issues::ListService, services: true do
end
end
end
context 'when :all_lists param is set' do
let(:params) { { board_id: board.id, all_lists: true, milestone_title: m1.title } }
it 'returns matching issues in all board lists' do
issues = described_class.new(parent, user, params).execute
expect(issues).to match_array([opened_issue1, list1_issue1,
list1_issue3, list2_issue1, closed_issue3])
end
end
end
end
......@@ -168,4 +181,5 @@ RSpec.describe Boards::Issues::ListService, services: true do
end
end
end
end
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