summaryrefslogtreecommitdiff
path: root/app/controllers/autocomplete_controller.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-11-30 00:06:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-11-30 00:06:03 +0000
commit7ddd5846999029916b2b6d8560b5b0f02ec0f6ea (patch)
tree0b570f83b5aacc9d79de9f1fbff9b8f9dca67482 /app/controllers/autocomplete_controller.rb
parent839c080dd0976f19c274eee1331c47985490cd41 (diff)
downloadgitlab-ce-7ddd5846999029916b2b6d8560b5b0f02ec0f6ea.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/controllers/autocomplete_controller.rb')
-rw-r--r--app/controllers/autocomplete_controller.rb16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb
index 06531932b31..ba8d2d18695 100644
--- a/app/controllers/autocomplete_controller.rb
+++ b/app/controllers/autocomplete_controller.rb
@@ -40,10 +40,20 @@ class AutocompleteController < ApplicationController
end
def merge_request_target_branches
- merge_requests = MergeRequestsFinder.new(current_user, params).execute
- target_branches = merge_requests.recent_target_branches
+ if target_branch_params.present?
+ merge_requests = MergeRequestsFinder.new(current_user, target_branch_params).execute
+ target_branches = merge_requests.recent_target_branches
+
+ render json: target_branches.map { |target_branch| { title: target_branch } }
+ else
+ render json: { error: _('At least one of group_id or project_id must be specified') }, status: :bad_request
+ end
+ end
+
+ private
- render json: target_branches.map { |target_branch| { title: target_branch } }
+ def target_branch_params
+ params.permit(:group_id, :project_id)
end
end