diff options
-rw-r--r-- | app/services/merge_requests/build_service.rb | 4 | ||||
-rw-r--r-- | changelogs/unreleased/24627-fix-bad-mr-error-message.yml | 4 | ||||
-rw-r--r-- | spec/features/merge_requests/create_new_mr_spec.rb | 7 |
3 files changed, 13 insertions, 2 deletions
diff --git a/app/services/merge_requests/build_service.rb b/app/services/merge_requests/build_service.rb index f415244068b..dd0d738674e 100644 --- a/app/services/merge_requests/build_service.rb +++ b/app/services/merge_requests/build_service.rb @@ -48,11 +48,11 @@ module MergeRequests end # See if source and target branches exist - unless merge_request.source_project.commit(merge_request.source_branch) + if merge_request.source_branch.present? && !merge_request.source_project.commit(merge_request.source_branch) messages << "Source branch \"#{merge_request.source_branch}\" does not exist" end - unless merge_request.target_project.commit(merge_request.target_branch) + if merge_request.target_branch.present? && !merge_request.target_project.commit(merge_request.target_branch) messages << "Target branch \"#{merge_request.target_branch}\" does not exist" end diff --git a/changelogs/unreleased/24627-fix-bad-mr-error-message.yml b/changelogs/unreleased/24627-fix-bad-mr-error-message.yml new file mode 100644 index 00000000000..d6a9818b2ce --- /dev/null +++ b/changelogs/unreleased/24627-fix-bad-mr-error-message.yml @@ -0,0 +1,4 @@ +--- +title: Fix regression causing bad error message to appear on Merge Request form +merge_request: 7599 +author: Alex Sanford diff --git a/spec/features/merge_requests/create_new_mr_spec.rb b/spec/features/merge_requests/create_new_mr_spec.rb index 584574cc91a..702869b6e8b 100644 --- a/spec/features/merge_requests/create_new_mr_spec.rb +++ b/spec/features/merge_requests/create_new_mr_spec.rb @@ -77,4 +77,11 @@ feature 'Create New Merge Request', feature: true, js: true do expect(page).to have_content "6049019_460s.jpg" end end + + # Isolates a regression (see #24627) + it 'does not show error messages on initial form' do + visit new_namespace_project_merge_request_path(project.namespace, project) + expect(page).not_to have_selector('#error_explanation') + expect(page).not_to have_content('The form contains the following error') + end end |