Skip to content
Snippets Groups Projects

Users can apply multiple suggestions at once.

Merged Jesse Hall requested to merge jessehall3/gitlab-ee:25486-batch-suggestions into master
6 files
+ 63
59
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 3
9
@@ -15,8 +15,6 @@ class Suggestions < Grape::API
suggestion = Suggestion.find_by_id(params[:id])
if suggestion
authorize! :apply_suggestion, suggestion
present_suggestions(suggestion, current_user)
else
render_api_error!(_('Suggestion is not applicable as the suggestion was not found.'), :not_found)
@@ -37,8 +35,6 @@ class Suggestions < Grape::API
suggestions = Suggestion.id_in(ids)
if suggestions.size == ids.length
authorize_suggestions(suggestions)
present_suggestions(suggestions, current_user)
else
render_api_error!(_('Suggestions are not applicable as one or more suggestions were not found.'), :not_found)
@@ -48,6 +44,8 @@ class Suggestions < Grape::API
helpers do
def present_suggestions(suggestions, current_user)
authorize_suggestions(*suggestions)
result = ::Suggestions::ApplyService.new(current_user).execute(*suggestions)
if result[:status] == :success
@@ -58,12 +56,8 @@ def present_suggestions(suggestions, current_user)
end
end
def authorize_suggestions(suggestions)
first_branch = suggestions.first.branch
def authorize_suggestions(*suggestions)
suggestions.each do |suggestion|
return forbidden! unless first_branch == suggestion.branch
authorize! :apply_suggestion, suggestion
end
end
Loading