Update Boards::Issues::ListService to list issues for a board list
This commit is contained in:
parent
1a4b1e9735
commit
1fa3f30811
2 changed files with 28 additions and 7 deletions
|
@ -10,6 +10,10 @@ module Boards
|
|||
|
||||
private
|
||||
|
||||
def board
|
||||
@board ||= project.boards.find(params[:board_id])
|
||||
end
|
||||
|
||||
def list
|
||||
@list ||= board.lists.find(params[:id])
|
||||
end
|
||||
|
|
|
@ -4,7 +4,7 @@ describe Boards::Issues::ListService, services: true do
|
|||
describe '#execute' do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project_with_board) }
|
||||
let(:board) { project.board }
|
||||
let(:board) { create(:board, project: project) }
|
||||
|
||||
let(:bug) { create(:label, project: project, name: 'Bug') }
|
||||
let(:development) { create(:label, project: project, name: 'Development') }
|
||||
|
@ -13,10 +13,10 @@ describe Boards::Issues::ListService, services: true do
|
|||
let(:p2) { create(:label, title: 'P2', project: project, priority: 2) }
|
||||
let(:p3) { create(:label, title: 'P3', project: project, priority: 3) }
|
||||
|
||||
let!(:backlog) { project.board.backlog_list }
|
||||
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!(:done) { project.board.done_list }
|
||||
let!(:done) { create(:done_list, board: board) }
|
||||
|
||||
let!(:opened_issue1) { create(:labeled_issue, project: project, labels: [bug]) }
|
||||
let!(:opened_issue2) { create(:labeled_issue, project: project, labels: [p2]) }
|
||||
|
@ -37,7 +37,7 @@ describe Boards::Issues::ListService, services: true do
|
|||
end
|
||||
|
||||
it 'delegates search to IssuesFinder' do
|
||||
params = { id: list1.id }
|
||||
params = { board_id: board.id, id: list1.id }
|
||||
|
||||
expect_any_instance_of(IssuesFinder).to receive(:execute).once.and_call_original
|
||||
|
||||
|
@ -46,7 +46,7 @@ describe Boards::Issues::ListService, services: true do
|
|||
|
||||
context 'sets default order to priority' do
|
||||
it 'returns opened issues when listing issues from Backlog' do
|
||||
params = { id: backlog.id }
|
||||
params = { board_id: board.id, id: backlog.id }
|
||||
|
||||
issues = described_class.new(project, user, params).execute
|
||||
|
||||
|
@ -54,7 +54,7 @@ describe Boards::Issues::ListService, services: true do
|
|||
end
|
||||
|
||||
it 'returns closed issues when listing issues from Done' do
|
||||
params = { id: done.id }
|
||||
params = { board_id: board.id, id: done.id }
|
||||
|
||||
issues = described_class.new(project, user, params).execute
|
||||
|
||||
|
@ -62,12 +62,29 @@ describe Boards::Issues::ListService, services: true do
|
|||
end
|
||||
|
||||
it 'returns opened issues that have label list applied when listing issues from a label list' do
|
||||
params = { id: list1.id }
|
||||
params = { board_id: board.id, id: list1.id }
|
||||
|
||||
issues = described_class.new(project, user, params).execute
|
||||
|
||||
expect(issues).to eq [list1_issue3, list1_issue1, list1_issue2]
|
||||
end
|
||||
end
|
||||
|
||||
context 'with list that does not belongs to the board' do
|
||||
it 'raises an error' do
|
||||
list = create(:list)
|
||||
service = described_class.new(project, user, board_id: board.id, id: list.id)
|
||||
|
||||
expect { service.execute }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with invalid list id' do
|
||||
it 'raises an error' do
|
||||
service = described_class.new(project, user, board_id: board.id, id: nil)
|
||||
|
||||
expect { service.execute }.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue