Commit dded02d1 authored by Eric Eastwood's avatar Eric Eastwood

Fix milestone page assignees when dropped in ongoing list

Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32861
parent 64e85fda
...@@ -65,14 +65,18 @@ ...@@ -65,14 +65,18 @@
}; };
Milestone.successCallback = function(data, element) { Milestone.successCallback = function(data, element) {
var img_tag; const $avatarContainer = $(element).find('.assignee-icon');
if (data.assignee) { $avatarContainer.empty();
img_tag = $('<img/>');
img_tag.attr('src', data.assignee.avatar_url); if (data.assignees && data.assignees.length > 0) {
img_tag.addClass('avatar s16'); const $avatars = data.assignees.map((assignee) => {
$(element).find('.assignee-icon img').replaceWith(img_tag); const img_tag = $('<img/>');
} else { img_tag.attr('src', assignee.avatar_url);
$(element).find('.assignee-icon').empty(); img_tag.addClass('avatar s16');
return img_tag;
});
$avatarContainer.append($avatars);
} }
}; };
...@@ -161,9 +165,9 @@ ...@@ -161,9 +165,9 @@
data = (function() { data = (function() {
switch (newState) { switch (newState) {
case 'ongoing': case 'ongoing':
return opts.fieldName + '[assignee_id]=' + gon.current_user_id; return `${opts.fieldName}[assignee_ids][]=${gon.current_user_id}`;
case 'unassigned': case 'unassigned':
return opts.fieldName + '[assignee_id]='; return `${opts.fieldName}[assignee_ids][]=0`;
case 'closed': case 'closed':
return opts.fieldName + '[state_event]=close'; return opts.fieldName + '[state_event]=close';
} }
......
...@@ -37,6 +37,14 @@ describe 'Milestone draggable', feature: true, js: true do ...@@ -37,6 +37,14 @@ describe 'Milestone draggable', feature: true, js: true do
expect(issue_target).to have_selector('.issuable-row') expect(issue_target).to have_selector('.issuable-row')
end end
it 'assigns issue when it has been dragged to ongoing list' do
login_as(:admin)
create_and_drag_issue
expect(@issue.reload.assignees).not_to be_empty
expect(page).to have_selector("#sortable_issue_#{@issue.iid} .assignee-icon img", count: 1)
end
end end
context 'merge requests' do context 'merge requests' do
...@@ -72,7 +80,7 @@ describe 'Milestone draggable', feature: true, js: true do ...@@ -72,7 +80,7 @@ describe 'Milestone draggable', feature: true, js: true do
end end
def create_and_drag_issue(params = {}) def create_and_drag_issue(params = {})
create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone)) @issue = create(:issue, params.merge(title: 'Foo', project: project, milestone: milestone))
visit namespace_project_milestone_path(project.namespace, project, milestone) visit namespace_project_milestone_path(project.namespace, project, milestone)
scroll_into_view('.milestone-content') scroll_into_view('.milestone-content')
......
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