diff options
author | Jacob Schatz <jschatz@gitlab.com> | 2016-06-15 14:04:42 +0300 |
---|---|---|
committer | Jacob Schatz <jschatz@gitlab.com> | 2016-06-15 14:04:42 +0300 |
commit | f28bbf9468458864ad5e883c48309a40ea99b63a (patch) | |
tree | 5dae2fbe84e163b8c461d3a6f21d8fe4fcda1707 | |
parent | 3a857e0e6c9460692f4b5d61e634205da9dee63a (diff) | |
parent | aa35abf9bf7ad528369bd8b54796f38cf68dfd96 (diff) |
Merge branch 'project-move-dropdown-search' into 'master'
Fixed issue with move dropdown not being searchable
## What does this MR do?
Adds the ability to search the project move dropdown.
## What are the relevant issue numbers?
Closes #18634
## Screenshots (if relevant)
![search](/uploads/f10a9a16b608308c1b3c66f186f57f80/search.gif)
See merge request !4666
-rw-r--r-- | app/assets/javascripts/issuable_form.js.coffee | 4 | ||||
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 1 | ||||
-rw-r--r-- | spec/features/issues/move_spec.rb | 16 |
3 files changed, 21 insertions, 0 deletions
diff --git a/app/assets/javascripts/issuable_form.js.coffee b/app/assets/javascripts/issuable_form.js.coffee index 898506fde32..5b7a4831dfc 100644 --- a/app/assets/javascripts/issuable_form.js.coffee +++ b/app/assets/javascripts/issuable_form.js.coffee @@ -102,6 +102,10 @@ class @IssuableForm return { results: data } + data: (query) -> + { + search: query + } formatResult: (project) -> project.name_with_namespace formatSelection: (project) -> diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index 3865b2d61fd..c89678cf2d8 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -35,6 +35,7 @@ class AutocompleteController < ApplicationController project = Project.find_by_id(params[:project_id]) projects = current_user.authorized_projects + projects = projects.search(params[:search]) if params[:search].present? projects = projects.select do |project| current_user.can?(:admin_issue, project) end diff --git a/spec/features/issues/move_spec.rb b/spec/features/issues/move_spec.rb index c7019c5aea1..7773c486b4e 100644 --- a/spec/features/issues/move_spec.rb +++ b/spec/features/issues/move_spec.rb @@ -26,6 +26,7 @@ feature 'issue move to another project' do context 'user has permission to move issue' do let!(:mr) { create(:merge_request, source_project: old_project) } let(:new_project) { create(:project) } + let(:new_project_search) { create(:project) } let(:text) { 'Text with !1' } let(:cross_reference) { old_project.to_reference } @@ -47,6 +48,21 @@ feature 'issue move to another project' do expect(page).to have_content(issue.title) end + scenario 'searching project dropdown', js: true do + new_project_search.team << [user, :reporter] + + page.within '.js-move-dropdown' do + first('.select2-choice').click + end + + fill_in('s2id_autogen2_search', with: new_project_search.name) + + page.within '.select2-drop' do + expect(page).to have_content(new_project_search.name) + expect(page).not_to have_content(new_project.name) + end + end + context 'user does not have permission to move the issue to a project', js: true do let!(:private_project) { create(:project, :private) } let(:another_project) { create(:project) } |