Commit 70f52918 authored by Stan Hu's avatar Stan Hu

Always add current user to autocomplete controller to support filter by "Me"

Partial fix #2202
parent caf4c0dd
Please view this file on the master branch, on stable branches it's out of date.
v 7.14.0 (unreleased)
- Always add current user to autocomplete controller to support filter by "Me" (Stan Hu)
- Fix multi-line syntax highlighting (Stan Hu)
- Fix network graph when branch name has single quotes (Stan Hu)
- Add "Confirm user" button in user admin page (Stan Hu)
......
......@@ -33,6 +33,8 @@ def users
@users = @users.search(params[:search]) if params[:search].present?
@users = @users.active
@users = @users.page(params[:page]).per(PER_PAGE)
# Always include current user if available to filter by "Me"
@users = User.find(@users.pluck(:id) + [current_user.id]).uniq if current_user
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
end
......
......@@ -138,10 +138,11 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
end
step 'I should see the users from the target project ID' do
expect(page).to have_selector('.user-result', visible: true, count: 2)
expect(page).to have_selector('.user-result', visible: true, count: 3)
users = page.all('.user-name')
expect(users[0].text).to eq 'Unassigned'
expect(users[1].text).to eq @project.users.first.name
expect(users[1].text).to eq current_user.name
expect(users[2].text).to eq @project.users.first.name
end
# Verify a link is generated against the correct project
......
......@@ -4,6 +4,7 @@
let!(:project) { create(:project) }
let!(:user) { create(:user) }
let!(:user2) { create(:user) }
let!(:non_member) { create(:user) }
context 'project members' do
before do
......@@ -61,6 +62,27 @@
end
end
context 'non-member login for public project' do
let!(:project) { create(:project, :public) }
before do
sign_in(non_member)
project.team << [user, :master]
end
let(:body) { JSON.parse(response.body) }
describe 'GET #users with project ID' do
before do
get(:users, project_id: project.id)
end
it { expect(body).to be_kind_of(Array) }
it { expect(body.size).to eq 2 }
it { expect(body.map { |u| u['username'] }).to match_array([user.username, non_member.username]) }
end
end
context 'all users' do
before do
sign_in(user)
......
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