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
def execute
create_board! if parent.boards.empty?
parent.boards
boards
end
private
def boards
parent.boards
end
def create_board!
Boards::CreateService.new(parent, current_user).execute
end
......
......@@ -11,6 +11,13 @@ module EE
super.limit(1)
end
end
private
override :boards
def boards
super.order('LOWER(name) ASC')
end
end
end
end
---
title: Order boards dropdown alphabetically
merge_request:
author:
type: changed
......@@ -3,9 +3,7 @@ require 'spec_helper'
describe Boards::ListService do
shared_examples 'boards list service' do
let(:service) { described_class.new(parent, double) }
before do
create_list(:board, 2, parent: parent)
end
let!(:boards) { create_list(:board, 3, parent: parent) }
describe '#execute' do
it 'returns all issue boards when multiple issue boards is enabled' do
......@@ -13,7 +11,7 @@ describe Boards::ListService do
stub_licensed_features(multiple_group_issue_boards: true)
end
expect(service.execute.size).to eq(2)
expect(service.execute.size).to eq(3)
end
it 'returns the first issue board when multiple issue boards is disabled' do
......@@ -23,6 +21,14 @@ describe Boards::ListService do
expect(service.execute.size).to eq(1)
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
......
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