Commit 71f46a2c authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Adjust board update service to update assignees

parent 03f74a31
...@@ -8,7 +8,14 @@ module Boards ...@@ -8,7 +8,14 @@ module Boards
params.delete(:weight) params.delete(:weight)
end end
set_assignee
board.update(params) board.update(params)
end end
def set_assignee
assignee = User.find_by(id: params.delete(:assignee_id))
params.merge!(assignee: assignee)
end
end end
end end
...@@ -25,24 +25,33 @@ describe Boards::UpdateService do ...@@ -25,24 +25,33 @@ describe Boards::UpdateService do
expect(service.execute(board)).to eq false expect(service.execute(board)).to eq false
end end
it 'updates the milestone with issue board milestones enabled' do it 'updates the configuration params when scoped issue board is enabled' do
stub_licensed_features(scoped_issue_board: true) stub_licensed_features(scoped_issue_board: true)
assignee = create(:user)
milestone = create(:milestone, project: project) milestone = create(:milestone, project: project)
label = create(:label, project: project)
service = described_class.new(project, double, milestone_id: milestone.id) service = described_class.new(project, double,
milestone_id: milestone.id,
assignee_id: assignee.id,
label_ids: [label.id])
service.execute(board) service.execute(board)
expect(board.reload.milestone).to eq(milestone) expect(board.reload).to have_attributes(milestone: milestone,
assignee: assignee,
labels: [label])
end end
it 'filters unpermitted params when scoped issue board is not enabled' do it 'filters unpermitted params when scoped issue board is not enabled' do
stub_licensed_features(scoped_issue_board: false) stub_licensed_features(scoped_issue_board: false)
params = { milestone_id: double, assignee_id: double, label_ids: double, weight: double } params = { milestone_id: double, assignee_id: double, label_ids: double, weight: double }
expect(board).to receive(:update).with({})
service = described_class.new(project, double, params) service = described_class.new(project, double, params)
service.execute(board) service.execute(board)
expect(board.reload).to have_attributes(milestone: nil,
assignee: nil,
labels: [])
end 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