Commit 191909bc authored by Douwe Maan's avatar Douwe Maan

Merge branch 'scoped-labels-ordering-fix' into 'master'

Fix selection of scoped labels

Closes #11158

See merge request gitlab-org/gitlab-ee!10993
parents 6f8cc02c 45e643f4
......@@ -28,7 +28,7 @@ class ScopedLabelSet
by_index = label_ids_order.map.with_index { |id, idx| [id.to_i, idx] }.to_h
label_ids.max do |id1, id2|
by_index[id1].to_i <=> by_index[id2].to_i
by_index.fetch(id1, -1) <=> by_index.fetch(id2, -1)
end
end
......
......@@ -84,5 +84,11 @@ describe ScopedLabelSet do
expect(set.last_id_by_order([kv_label1.id, kv_label3.id, kv_label2.id])).to eq(kv_label3.id)
end
it 'returns last label present in the set ordered by custom order if there is single item' do
set = described_class.new('key', [kv_label1, kv_label3])
expect(set.last_id_by_order([kv_label3.id])).to eq(kv_label3.id)
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