Commit e73269a0 authored by Douwe Maan's avatar Douwe Maan

Fix Mirror User dropdown

parent 9b5e4b69
......@@ -7,6 +7,7 @@ v 8.5.0 (unreleased)
v 8.4.3
- Elasticsearch: fix partial blob indexing on push
- Elasticsearch: added advanced indexer for repositories
- Fix Mirror User dropdown
v 8.4.2
- Elasticsearch indexer performance improvements
......
......@@ -8,7 +8,8 @@ class AutocompleteController < ApplicationController
@users = @users.active
@users = @users.reorder(:name)
if params[:push_code_to_protected_branches].present? && project
if params[:push_code_to_protected_branches].present? && params[:project_id].present?
project = Project.find_by(id: params[:project_id])
@users = @users.to_a.select { |user| user.can?(:push_code_to_protected_branches, project) }.take(PER_PAGE)
else
@users = @users.page(params[:page]).per(PER_PAGE)
......
......@@ -10,6 +10,7 @@ describe AutocompleteController do
before do
sign_in(user)
project.team << [user, :master]
project.team << [user2, :developer]
end
let(:body) { JSON.parse(response.body) }
......@@ -20,7 +21,7 @@ describe AutocompleteController do
end
it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq 1 }
it { expect(body.size).to eq 2 }
it { expect(body.first["username"]).to eq user.username }
end
......@@ -31,6 +32,16 @@ describe AutocompleteController do
it { expect(response.status).to eq(404) }
end
describe "GET #users that can push to protected branches" do
before do
get(:users, project_id: project.id, push_code_to_protected_branches: 'true')
end
it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq 1 }
it { expect(body.first["username"]).to eq user.username }
end
end
context 'group members' 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