throw(:error,error(_(%q(You are not allowed to push into this branch. Create another branch or open a merge request.)),:forbidden))unlesspush_authorized?
returnerror(_(%q(There was an error updating the dashboard, branch name is invalid.)),:bad_request)unlessvalid_branch_name?
returnerror(_('There was an error updating the dashboard, branch named: %{branch} already exists.')%{branch: params[:branch]},:bad_request)unlessnew_or_default_branch?
returnerror(_(%q(The file name should have a .yml extension)),:bad_request)unlesstarget_file_type_valid?
success(result)
end
# rubocop:disable Cop/BanCatchThrow
defbranch
@branch||=begin
throw(:error,error(_('There was an error updating the dashboard, branch name is invalid.'),:bad_request))unlessvalid_branch_name?
throw(:error,error(_('There was an error updating the dashboard, branch named: %{branch} already exists.')%{branch: params[:branch]},:bad_request))unlessnew_or_default_branch?
context'user does not have push right to repository'do
it_behaves_like'misconfigured dashboard service response',:forbidden,"You are not allowed to push into this branch. Create another branch or open a merge request."
it'returns an appropriate message and status code',:aggregate_failuresdo
it_behaves_like'misconfigured dashboard service response',:bad_request,"There was an error updating the dashboard, branch named: existing_branch already exists."
it'returns an appropriate message and status code',:aggregate_failuresdo