Commit e7642dd9 authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Add board assignee, weight, labels and milestone when creating a board issue

parent 394ca1bc
......@@ -10,11 +10,18 @@ module Boards
end
def execute
create_issue(params.merge(label_ids: [list.label_id]))
create_issue(creation_params)
end
private
def creation_params
params.merge(label_ids: [list.label_id, *board.label_ids],
weight: board.weight,
milestone_id: board.milestone_id,
assignee_ids: [board.assignee_id])
end
def board
@board ||= parent.boards.find(params.delete(:board_id))
end
......
......@@ -29,5 +29,23 @@ describe Boards::Issues::CreateService do
expect(issue.labels).to eq [label]
end
it 'adds the board assignee, weight, labels and milestone to the issue' do
board_assignee = create(:user)
project.team << [board_assignee, :developer]
board_milestone = create(:milestone, project: project)
board_label = create(:label, project: project)
board.update!(assignee: board_assignee,
milestone: board_milestone,
label_ids: [board_label.id],
weight: 4)
issue = service.execute
expect(issue.assignees).to eq([board_assignee])
expect(issue.weight).to eq(board.weight)
expect(issue.milestone).to eq(board_milestone)
expect(issue.labels).to contain_exactly(label, board_label)
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