Commit b0595414 authored by Douwe Maan's avatar Douwe Maan

Merge branch '32977-user-autocomplete-per_page-does-not-work-ee' into 'master'

Add per page to user autocomplete (EE)

See merge request !1991
parents 817c1151 21a896b5
......@@ -9,7 +9,7 @@ class AutocompleteController < ApplicationController
@users = @users.where.not(id: params[:skip_users]) if params[:skip_users].present?
@users = @users.active
@users = @users.reorder(:name)
@users = load_users_by_ability || @users.page(params[:page])
@users = load_users_by_ability || @users.page(params[:page]).per(params[:per_page])
if params[:todo_filter].present? && current_user
@users = @users.todo_authors(current_user.id, params[:todo_state_filter])
......@@ -63,7 +63,7 @@ class AutocompleteController < ApplicationController
@users.to_a
.select { |user| user.can?(ability, @project) }
.take(Kaminari.config.default_per_page)
.take(params[:per_page]&.to_i || Kaminari.config.default_per_page)
end
def find_users
......
......@@ -137,6 +137,20 @@ describe AutocompleteController do
it { expect(body.size).to eq User.count }
end
context 'limited users per page' do
let(:per_page) { 2 }
before do
sign_in(user)
get(:users, per_page: per_page)
end
let(:body) { JSON.parse(response.body) }
it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq per_page }
end
context 'unauthenticated user' do
let(:public_project) { create(:project, :public) }
let(:body) { JSON.parse(response.body) }
......
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