Module: API::Helpers::MergeRequestsHelpers

Extended by:
ActiveSupport::Concern, Grape::API::Helpers
Defined in:
lib/api/helpers/merge_requests_helpers.rb

Constant Summary collapse

UNPROCESSABLE_ERROR_KEYS =
[:project_access, :branch_conflict, :validate_fork, :base].freeze

Instance Method Summary collapse

Instance Method Details

#handle_merge_request_errors!(merge_request) ⇒ Object


86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/api/helpers/merge_requests_helpers.rb', line 86

def handle_merge_request_errors!(merge_request)
  return if merge_request.valid?

  errors = merge_request.errors

  UNPROCESSABLE_ERROR_KEYS.each do |error|
    unprocessable_entity!(errors[error]) if errors.has_key?(error)
  end

  conflict!(errors[:validate_branches]) if errors.has_key?(:validate_branches)

  render_validation_error!(merge_request)
end