Commit 70672182 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'fix-bulk-assign-labels' into 'master'

Fixes bulk-assign label for multiple issues not having the same labels

## What does this MR do?
Fixes a bug when bulk-assigning a label to multiple issues while the label is present in on the issues on the selection.

## Screenshots (if relevant)

**Before Bugfix**

<img src="/uploads/ad1f290bcf3930177a3a71c69cbe5325/before-bugfix.gif" width="700"/>

**After Bugfix**

<img src="/uploads/1f04d6bf027806fb13ca3773febda744/bugfix.gif" width="700"/>

## Does this MR meet the acceptance criteria?

- [x] Tests
  - [x] Added for this feature/bug
  - [x] All builds are passing
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)

See merge request !4602
parents 9fdadfc0 952660d2
......@@ -97,13 +97,22 @@ class @IssuableBulkActions
$labels = @form.find('.labels-filter input[name="update[label_ids][]"]')
$labels.each (k, label) ->
labelIds.push $(label).val() if label
labelIds.push parseInt($(label).val()) if label
labelIds
###*
* Just an alias of @getUnmarkedIndeterminedLabels
* @return {Array} Array of labels
* Returns Label IDs that will be removed from issue selection
* @return {Array} Array of labels IDs
###
getLabelsToRemove: ->
@getUnmarkedIndeterminedLabels()
result = []
indeterminatedLabels = @getUnmarkedIndeterminedLabels()
labelsToApply = @getLabelsToApply()
indeterminatedLabels.map (id) ->
# We need to exclude label IDs that will be applied
# By not doing this will cause issues from selection to not add labels at all
result.push(id) if labelsToApply.indexOf(id) is -1
result
......@@ -83,6 +83,23 @@ feature 'Issues > Labels bulk assignment', feature: true do
end
end
context 'can assign a label to all issues when label is present' do
before do
issue2.labels << bug
issue2.labels << feature
visit namespace_project_issues_path(project.namespace, project)
check 'check_all_issues'
open_labels_dropdown ['bug']
update_issues
end
it do
expect(find("#issue_#{issue1.id}")).to have_content 'bug'
expect(find("#issue_#{issue2.id}")).to have_content 'bug'
end
end
context 'can bulk un-assign' do
context 'all labels to all issues' do
before do
......
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