From 63b2b1b426d29992b997eff536052f6073e38415 Mon Sep 17 00:00:00 2001 From: Phil Hughes Date: Mon, 22 Oct 2018 10:29:46 +0100 Subject: [PATCH] Fixed source projects not filtering Filtering source projects in the merge request creation form would show a flash error because it is trying to filter remotely to an undefined URL. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/52728 --- .../javascripts/compare_autocomplete.js | 2 +- .../mr-creation-source-project-filtering.yml | 5 ++++ .../merge_request/user_creates_mr_spec.rb | 25 +++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 changelogs/unreleased/mr-creation-source-project-filtering.yml diff --git a/app/assets/javascripts/compare_autocomplete.js b/app/assets/javascripts/compare_autocomplete.js index 852d71f4e84..37a3ceb5341 100644 --- a/app/assets/javascripts/compare_autocomplete.js +++ b/app/assets/javascripts/compare_autocomplete.js @@ -40,7 +40,7 @@ export default function initCompareAutocomplete(limitTo = null, clickHandler = ( }, selectable: true, filterable: true, - filterRemote: true, + filterRemote: !!$dropdown.data('refsUrl'), fieldName: $dropdown.data('fieldName'), filterInput: 'input[type="search"]', renderRow: function(ref) { diff --git a/changelogs/unreleased/mr-creation-source-project-filtering.yml b/changelogs/unreleased/mr-creation-source-project-filtering.yml new file mode 100644 index 00000000000..818101a6f1b --- /dev/null +++ b/changelogs/unreleased/mr-creation-source-project-filtering.yml @@ -0,0 +1,5 @@ +--- +title: Fixed source project not filtering in merge request creation compare form +merge_request: +author: +type: fixed diff --git a/spec/features/merge_request/user_creates_mr_spec.rb b/spec/features/merge_request/user_creates_mr_spec.rb index 1ac31de62cb..9d2a94a4a41 100644 --- a/spec/features/merge_request/user_creates_mr_spec.rb +++ b/spec/features/merge_request/user_creates_mr_spec.rb @@ -28,4 +28,29 @@ describe 'Merge request > User creates MR' do it_behaves_like 'a creatable merge request' end end + + context 'source project', :js do + let(:user) { create(:user) } + let(:target_project) { create(:project, :public, :repository) } + let(:source_project) { target_project } + + before do + source_project.add_maintainer(user) + + sign_in(user) + visit project_new_merge_request_path( + target_project, + merge_request: { + source_project_id: source_project.id, + target_project_id: target_project.id + }) + end + + it 'filters source project' do + find('.js-source-project').click + find('.dropdown-source-project input').set('source') + + expect(find('.dropdown-source-project .dropdown-content')).not_to have_content(source_project.name) + end + end end