2019-04-11 12:17:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-03 00:14:50 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Boards::Issues::ListService do
|
2016-08-03 00:14:50 +00:00
|
|
|
describe '#execute' do
|
2018-02-19 19:06:16 +00:00
|
|
|
context 'when parent is a project' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
let(:board) { create(:board, project: project) }
|
|
|
|
|
|
|
|
let(:m1) { create(:milestone, project: project) }
|
|
|
|
let(:m2) { create(:milestone, project: project) }
|
|
|
|
|
|
|
|
let(:bug) { create(:label, project: project, name: 'Bug') }
|
|
|
|
let(:development) { create(:label, project: project, name: 'Development') }
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:testing) { create(:label, project: project, name: 'Testing') }
|
2018-02-19 19:06:16 +00:00
|
|
|
let(:p1) { create(:label, title: 'P1', project: project, priority: 1) }
|
|
|
|
let(:p2) { create(:label, title: 'P2', project: project, priority: 2) }
|
|
|
|
let(:p3) { create(:label, title: 'P3', project: project, priority: 3) }
|
|
|
|
|
|
|
|
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, title: 'Issue 1', labels: [bug]) }
|
|
|
|
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2]) }
|
2018-09-13 22:45:58 +00:00
|
|
|
let!(:reopened_issue1) { create(:issue, :opened, project: project, title: 'Reopened Issue 1' ) }
|
2018-02-19 19:06:16 +00:00
|
|
|
|
|
|
|
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: project, milestone: m1, labels: [development, p1]) }
|
|
|
|
let!(:list2_issue1) { create(:labeled_issue, project: project, 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: project) }
|
|
|
|
let!(:closed_issue4) { create(:labeled_issue, :closed, project: project, labels: [p1]) }
|
|
|
|
let!(:closed_issue5) { create(:labeled_issue, :closed, project: project, labels: [development]) }
|
|
|
|
|
|
|
|
let(:parent) { project }
|
|
|
|
|
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
2016-08-03 00:14:50 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
it_behaves_like 'issues list service'
|
2018-09-13 22:45:58 +00:00
|
|
|
|
|
|
|
context 'when project is archived' do
|
|
|
|
let(:project) { create(:project, :archived) }
|
|
|
|
|
|
|
|
it_behaves_like 'issues list service'
|
|
|
|
end
|
2016-08-03 00:14:50 +00:00
|
|
|
end
|
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
context 'when parent is a group' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :empty_repo, namespace: group) }
|
|
|
|
let(:project1) { create(:project, :empty_repo, namespace: group) }
|
2018-09-13 22:45:58 +00:00
|
|
|
let(:project_archived) { create(:project, :empty_repo, :archived, namespace: group) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let(:m1) { create(:milestone, group: group) }
|
|
|
|
let(:m2) { create(:milestone, group: group) }
|
2017-05-31 14:34:02 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let(:bug) { create(:group_label, group: group, name: 'Bug') }
|
|
|
|
let(:development) { create(:group_label, group: group, name: 'Development') }
|
2019-01-16 12:09:29 +00:00
|
|
|
let(:testing) { create(:group_label, group: group, name: 'Testing') }
|
2017-05-31 14:34:02 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
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) }
|
2017-05-31 14:34:02 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let(:p1_project) { create(:label, title: 'P1_project', project: project, priority: 1) }
|
|
|
|
let(:p2_project) { create(:label, title: 'P2_project', project: project, priority: 2) }
|
|
|
|
let(:p3_project) { create(:label, title: 'P3_project', project: project, priority: 3) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let(:p1_project1) { create(:label, title: 'P1_project1', project: project1, priority: 1) }
|
|
|
|
let(:p2_project1) { create(:label, title: 'P2_project1', project: project1, priority: 2) }
|
|
|
|
let(:p3_project1) { create(:label, title: 'P3_project1', project: project1, priority: 3) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
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) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
|
|
|
|
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2, p2_project]) }
|
2018-09-13 22:45:58 +00:00
|
|
|
let!(:opened_issue3) { create(:labeled_issue, project: project_archived, milestone: m1, title: 'Issue 3', labels: [bug]) }
|
|
|
|
let!(:reopened_issue1) { create(:issue, state: 'opened', project: project, title: 'Reopened Issue 1', closed_at: Time.now ) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let!(:list1_issue1) { create(:labeled_issue, project: project, milestone: m1, labels: [p2, p2_project, 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, p1_project1]) }
|
|
|
|
let!(:list2_issue1) { create(:labeled_issue, project: project1, milestone: m1, labels: [testing]) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
let!(:closed_issue1) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
|
|
|
|
let!(:closed_issue2) { create(:labeled_issue, :closed, project: project, labels: [p3, p3_project]) }
|
|
|
|
let!(:closed_issue3) { create(:issue, :closed, project: project1) }
|
|
|
|
let!(:closed_issue4) { create(:labeled_issue, :closed, project: project1, labels: [p1, p1_project1]) }
|
|
|
|
let!(:closed_issue5) { create(:labeled_issue, :closed, project: project1, labels: [development]) }
|
2017-03-07 16:04:44 +00:00
|
|
|
|
2018-02-19 19:06:16 +00:00
|
|
|
before do
|
|
|
|
group.add_developer(user)
|
2016-10-05 17:26:28 +00:00
|
|
|
end
|
|
|
|
|
2018-04-04 21:43:33 +00:00
|
|
|
context 'and group has no parent' do
|
|
|
|
let(:parent) { group }
|
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:board) { create(:board, group: group) }
|
|
|
|
|
|
|
|
it_behaves_like 'issues list service'
|
|
|
|
end
|
|
|
|
|
2019-07-24 09:20:54 +00:00
|
|
|
context 'and group is an ancestor' do
|
2018-04-04 21:43:33 +00:00
|
|
|
let(:parent) { create(:group) }
|
|
|
|
let(:group) { create(:group, parent: parent) }
|
|
|
|
let!(:backlog) { create(:backlog_list, board: board) }
|
|
|
|
let(:board) { create(:board, group: parent) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
parent.add_developer(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it_behaves_like 'issues list service'
|
|
|
|
end
|
2016-10-06 02:50:35 +00:00
|
|
|
end
|
2016-08-03 00:14:50 +00:00
|
|
|
end
|
|
|
|
end
|