diff options
author | Eric Eastwood <contact@ericeastwood.com> | 2017-06-09 18:07:50 -0500 |
---|---|---|
committer | Eric Eastwood <contact@ericeastwood.com> | 2017-06-09 18:07:50 -0500 |
commit | 4d74df256b9d0c5ca6dcb90a0b65ffc5f6809764 (patch) | |
tree | a60caddae4a03b27014d88ad0afb957116cc3992 | |
parent | b16730fc8317b282d5dc86dbc8936c74303f5a36 (diff) | |
download | gitlab-ce-32861-fix-milestone-drag-and-drop-assignees.tar.gz |
Fix milestone page assignees when dropped in ongoing list32861-fix-milestone-drag-and-drop-assignees
Fix https://gitlab.com/gitlab-org/gitlab-ce/issues/32861
-rw-r--r-- | app/assets/javascripts/milestone.js | 16 | ||||
-rw-r--r-- | spec/features/milestones/milestones_spec.rb | 9 |
2 files changed, 17 insertions, 8 deletions
diff --git a/app/assets/javascripts/milestone.js b/app/assets/javascripts/milestone.js index 841b24a60a3..3137578a11f 100644 --- a/app/assets/javascripts/milestone.js +++ b/app/assets/javascripts/milestone.js @@ -66,11 +66,13 @@ Milestone.successCallback = function(data, element) { var img_tag; - if (data.assignee) { - img_tag = $('<img/>'); - img_tag.attr('src', data.assignee.avatar_url); - img_tag.addClass('avatar s16'); - $(element).find('.assignee-icon img').replaceWith(img_tag); + if (data.assignees && data.assignees.length > 0) { + data.assignees.forEach((assignee) => { + img_tag = $('<img/>'); + img_tag.attr('src', assignee.avatar_url); + img_tag.addClass('avatar s16'); + $(element).find('.assignee-icon').append(img_tag); + }); } else { $(element).find('.assignee-icon').empty(); } @@ -161,9 +163,9 @@ data = (function() { switch (newState) { case 'ongoing': - return opts.fieldName + '[assignee_id]=' + gon.current_user_id; + return `${opts.fieldName}[assignee_ids][]=${gon.current_user_id}`; case 'unassigned': - return opts.fieldName + '[assignee_id]='; + return `${opts.fieldName}[assignee_ids][]=0`; case 'closed': return opts.fieldName + '[state_event]=close'; } diff --git a/spec/features/milestones/milestones_spec.rb b/spec/features/milestones/milestones_spec.rb index b3dfd6d0e81..f1fde879571 100644 --- a/spec/features/milestones/milestones_spec.rb +++ b/spec/features/milestones/milestones_spec.rb @@ -37,6 +37,13 @@ describe 'Milestone draggable', feature: true, js: true do expect(issue_target).to have_selector('.issuable-row') 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 + end end context 'merge requests' do @@ -72,7 +79,7 @@ describe 'Milestone draggable', feature: true, js: true do end 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) scroll_into_view('.milestone-content') |