Merge branch 'fix-email-autocomplete' into 'master'
Fix bug preventing invite by e-mail
This was broken in 70f5291808
as a result of introducing the ability to filter by current user.
Closes #2320
See merge request !1181
This commit is contained in:
commit
0daa21ed8c
9 changed files with 41 additions and 9 deletions
|
@ -6,6 +6,7 @@ class @UsersSelect
|
||||||
$('.ajax-users-select').each (i, select) =>
|
$('.ajax-users-select').each (i, select) =>
|
||||||
@projectId = $(select).data('project-id')
|
@projectId = $(select).data('project-id')
|
||||||
@groupId = $(select).data('group-id')
|
@groupId = $(select).data('group-id')
|
||||||
|
@showCurrentUser = $(select).data('current-user')
|
||||||
showNullUser = $(select).data('null-user')
|
showNullUser = $(select).data('null-user')
|
||||||
showAnyUser = $(select).data('any-user')
|
showAnyUser = $(select).data('any-user')
|
||||||
showEmailUser = $(select).data('email-user')
|
showEmailUser = $(select).data('email-user')
|
||||||
|
@ -108,6 +109,7 @@ class @UsersSelect
|
||||||
active: true
|
active: true
|
||||||
project_id: @projectId
|
project_id: @projectId
|
||||||
group_id: @groupId
|
group_id: @groupId
|
||||||
|
current_user: @showCurrentUser
|
||||||
dataType: "json"
|
dataType: "json"
|
||||||
).done (users) ->
|
).done (users) ->
|
||||||
callback(users)
|
callback(users)
|
||||||
|
|
|
@ -33,8 +33,14 @@ class AutocompleteController < ApplicationController
|
||||||
@users = @users.search(params[:search]) if params[:search].present?
|
@users = @users.search(params[:search]) if params[:search].present?
|
||||||
@users = @users.active
|
@users = @users.active
|
||||||
@users = @users.page(params[:page]).per(PER_PAGE)
|
@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
|
unless params[:search].present?
|
||||||
|
# Include current user if available to filter by "Me"
|
||||||
|
if params[:current_user] && current_user
|
||||||
|
@users = [*@users, current_user].uniq
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
|
render json: @users, only: [:name, :username, :id], methods: [:avatar_url]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ module SelectsHelper
|
||||||
any_user = opts[:any_user] || false
|
any_user = opts[:any_user] || false
|
||||||
email_user = opts[:email_user] || false
|
email_user = opts[:email_user] || false
|
||||||
first_user = opts[:first_user] && current_user ? current_user.username : false
|
first_user = opts[:first_user] && current_user ? current_user.username : false
|
||||||
|
current_user = opts[:current_user] || false
|
||||||
project = opts[:project] || @project
|
project = opts[:project] || @project
|
||||||
|
|
||||||
html = {
|
html = {
|
||||||
|
@ -18,7 +19,8 @@ module SelectsHelper
|
||||||
'data-null-user' => null_user,
|
'data-null-user' => null_user,
|
||||||
'data-any-user' => any_user,
|
'data-any-user' => any_user,
|
||||||
'data-email-user' => email_user,
|
'data-email-user' => email_user,
|
||||||
'data-first-user' => first_user
|
'data-first-user' => first_user,
|
||||||
|
'data-current-user' => current_user
|
||||||
}
|
}
|
||||||
|
|
||||||
unless opts[:scope] == :all
|
unless opts[:scope] == :all
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
none
|
none
|
||||||
.issuable-context-selectbox
|
.issuable-context-selectbox
|
||||||
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
|
- if can?(current_user, :"admin_#{issuable.to_ability_name}", @project)
|
||||||
= users_select_tag("#{issuable.class.table_name.singularize}[assignee_id]", placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: issuable.assignee_id, project: @target_project, null_user: true)
|
= users_select_tag("#{issuable.class.table_name.singularize}[assignee_id]", placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: issuable.assignee_id, project: @target_project, null_user: true, current_user: true)
|
||||||
|
|
||||||
%div.prepend-top-20.clearfix
|
%div.prepend-top-20.clearfix
|
||||||
.issuable-context-title
|
.issuable-context-title
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
.issues-other-filters
|
.issues-other-filters
|
||||||
.filter-item.inline
|
.filter-item.inline
|
||||||
= users_select_tag(:assignee_id, selected: params[:assignee_id],
|
= users_select_tag(:assignee_id, selected: params[:assignee_id],
|
||||||
placeholder: 'Assignee', class: 'trigger-submit', any_user: true, null_user: true, first_user: true)
|
placeholder: 'Assignee', class: 'trigger-submit', any_user: true, null_user: true, first_user: true, current_user: true)
|
||||||
|
|
||||||
.filter-item.inline
|
.filter-item.inline
|
||||||
= users_select_tag(:author_id, selected: params[:author_id],
|
= users_select_tag(:author_id, selected: params[:author_id],
|
||||||
placeholder: 'Author', class: 'trigger-submit', any_user: true, first_user: true)
|
placeholder: 'Author', class: 'trigger-submit', any_user: true, first_user: true, current_user: true)
|
||||||
|
|
||||||
.filter-item.inline.milestone-filter
|
.filter-item.inline.milestone-filter
|
||||||
= select_tag('milestone_title', projects_milestones_options,
|
= select_tag('milestone_title', projects_milestones_options,
|
||||||
|
@ -60,7 +60,7 @@
|
||||||
.issues_bulk_update.hide
|
.issues_bulk_update.hide
|
||||||
= form_tag bulk_update_namespace_project_issues_path(@project.namespace, @project), method: :post do
|
= form_tag bulk_update_namespace_project_issues_path(@project.namespace, @project), method: :post do
|
||||||
= select_tag('update[state_event]', options_for_select([['Open', 'reopen'], ['Closed', 'close']]), prompt: "Status", class: 'form-control')
|
= select_tag('update[state_event]', options_for_select([['Open', 'reopen'], ['Closed', 'close']]), prompt: "Status", class: 'form-control')
|
||||||
= users_select_tag('update[assignee_id]', placeholder: 'Assignee', null_user: true)
|
= users_select_tag('update[assignee_id]', placeholder: 'Assignee', null_user: true, first_user: true, current_user: true)
|
||||||
= select_tag('update[milestone_id]', bulk_update_milestone_options, prompt: "Milestone")
|
= select_tag('update[milestone_id]', bulk_update_milestone_options, prompt: "Milestone")
|
||||||
= hidden_field_tag 'update[issues_ids]', []
|
= hidden_field_tag 'update[issues_ids]', []
|
||||||
= hidden_field_tag :state_event, params[:state_event]
|
= hidden_field_tag :state_event, params[:state_event]
|
||||||
|
|
|
@ -47,7 +47,8 @@
|
||||||
.col-sm-10
|
.col-sm-10
|
||||||
= users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]",
|
= users_select_tag("#{issuable.class.model_name.param_key}[assignee_id]",
|
||||||
placeholder: 'Select a user', class: 'custom-form-control', null_user: true,
|
placeholder: 'Select a user', class: 'custom-form-control', null_user: true,
|
||||||
selected: issuable.assignee_id, project: @target_project || @project)
|
selected: issuable.assignee_id, project: @target_project || @project,
|
||||||
|
first_user: true, current_user: true)
|
||||||
|
|
||||||
= link_to 'Assign to me', '#', class: 'btn assign-to-me-link'
|
= link_to 'Assign to me', '#', class: 'btn assign-to-me-link'
|
||||||
.form-group
|
.form-group
|
||||||
|
|
|
@ -27,3 +27,9 @@ Feature: Admin Groups
|
||||||
When I visit admin group page
|
When I visit admin group page
|
||||||
And I remove user "John Doe" from group
|
And I remove user "John Doe" from group
|
||||||
Then I should not see "John Doe" in team list
|
Then I should not see "John Doe" in team list
|
||||||
|
|
||||||
|
@javascript
|
||||||
|
Scenario: Invite user to a group by e-mail
|
||||||
|
When I visit admin group page
|
||||||
|
When I select user "johndoe@gitlab.com" from user list as "Reporter"
|
||||||
|
Then I should see "johndoe@gitlab.com" in team list in every project as "Reporter"
|
||||||
|
|
|
@ -44,6 +44,14 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
|
||||||
click_button "Add users to group"
|
click_button "Add users to group"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When 'I select user "johndoe@gitlab.com" from user list as "Reporter"' do
|
||||||
|
select2('johndoe@gitlab.com', from: "#user_ids", multiple: true)
|
||||||
|
page.within "#new_project_member" do
|
||||||
|
select "Reporter", from: "access_level"
|
||||||
|
end
|
||||||
|
click_button "Add users to group"
|
||||||
|
end
|
||||||
|
|
||||||
step 'I should see "John Doe" in team list in every project as "Reporter"' do
|
step 'I should see "John Doe" in team list in every project as "Reporter"' do
|
||||||
page.within ".group-users-list" do
|
page.within ".group-users-list" do
|
||||||
expect(page).to have_content "John Doe"
|
expect(page).to have_content "John Doe"
|
||||||
|
@ -51,6 +59,13 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
step 'I should see "johndoe@gitlab.com" in team list in every project as "Reporter"' do
|
||||||
|
page.within ".group-users-list" do
|
||||||
|
expect(page).to have_content "johndoe@gitlab.com (invited)"
|
||||||
|
expect(page).to have_content "Reporter"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
step 'I should be all groups' do
|
step 'I should be all groups' do
|
||||||
Group.all.each do |group|
|
Group.all.each do |group|
|
||||||
expect(page).to have_content group.name
|
expect(page).to have_content group.name
|
||||||
|
|
|
@ -74,7 +74,7 @@ describe AutocompleteController do
|
||||||
|
|
||||||
describe 'GET #users with project ID' do
|
describe 'GET #users with project ID' do
|
||||||
before do
|
before do
|
||||||
get(:users, project_id: project.id)
|
get(:users, project_id: project.id, current_user: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
it { expect(body).to be_kind_of(Array) }
|
it { expect(body).to be_kind_of(Array) }
|
||||||
|
|
Loading…
Reference in a new issue