Commit 0c16b08b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'osw-order-boards-by-name-ee' into 'master'

Order boards dropdown alphabetically

Closes #4916

See merge request gitlab-org/gitlab-ee!5153
parents c7ec27fc 84ad1a41
...@@ -4,11 +4,15 @@ module Boards ...@@ -4,11 +4,15 @@ module Boards
def execute def execute
create_board! if parent.boards.empty? create_board! if parent.boards.empty?
parent.boards boards
end end
private private
def boards
parent.boards
end
def create_board! def create_board!
Boards::CreateService.new(parent, current_user).execute Boards::CreateService.new(parent, current_user).execute
end end
......
...@@ -11,6 +11,13 @@ module EE ...@@ -11,6 +11,13 @@ module EE
super.limit(1) super.limit(1)
end end
end end
private
override :boards
def boards
super.order('LOWER(name) ASC')
end
end end
end end
end end
---
title: Order boards dropdown alphabetically
merge_request:
author:
type: changed
...@@ -3,9 +3,7 @@ require 'spec_helper' ...@@ -3,9 +3,7 @@ require 'spec_helper'
describe Boards::ListService do describe Boards::ListService do
shared_examples 'boards list service' do shared_examples 'boards list service' do
let(:service) { described_class.new(parent, double) } let(:service) { described_class.new(parent, double) }
before do let!(:boards) { create_list(:board, 3, parent: parent) }
create_list(:board, 2, parent: parent)
end
describe '#execute' do describe '#execute' do
it 'returns all issue boards when multiple issue boards is enabled' do it 'returns all issue boards when multiple issue boards is enabled' do
...@@ -13,7 +11,7 @@ describe Boards::ListService do ...@@ -13,7 +11,7 @@ describe Boards::ListService do
stub_licensed_features(multiple_group_issue_boards: true) stub_licensed_features(multiple_group_issue_boards: true)
end end
expect(service.execute.size).to eq(2) expect(service.execute.size).to eq(3)
end end
it 'returns the first issue board when multiple issue boards is disabled' do it 'returns the first issue board when multiple issue boards is disabled' do
...@@ -23,6 +21,14 @@ describe Boards::ListService do ...@@ -23,6 +21,14 @@ describe Boards::ListService do
expect(service.execute.size).to eq(1) expect(service.execute.size).to eq(1)
end end
it 'returns boards ordered by name' do
board_names = ['a-board', 'B-board', 'c-board'].shuffle
boards.each_with_index { |board, i| board.update_column(:name, board_names[i]) }
stub_licensed_features(multiple_group_issue_boards: true)
expect(service.execute.pluck(:name)).to eq(['a-board', 'B-board', 'c-board'])
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