Commit 94badb64 authored by Douwe Maan's avatar Douwe Maan Committed by Alessio Caiazza

Merge branch 'bvl-validate-label-for-project-before-save-ce' into 'master'

[CE-Backport] Skip creating project when errors were added

See merge request !19430
parent 6640e8d4
Pipeline #23328453 failed with stages
in 39 minutes and 17 seconds
......@@ -46,6 +46,9 @@ module Projects
yield(@project) if block_given?
# If the block added errors, don't try to save the project
return @project if @project.errors.any?
@project.creator = current_user
if forked_from_project_id
......
......@@ -17,6 +17,11 @@ module Projects
ensure_wiki_exists if enabling_wiki?
yield if block_given?
# If the block added errors, don't try to save the project
return validation_failed! if project.errors.any?
if project.update_attributes(params.except(:default_branch))
if project.previous_changes.include?('path')
project.rename_repo
......@@ -28,10 +33,7 @@ module Projects
success
else
model_errors = project.errors.full_messages.to_sentence
error_message = model_errors.presence || 'Project could not be updated!'
error(error_message)
validation_failed!
end
end
......@@ -43,6 +45,13 @@ module Projects
private
def validation_failed!
model_errors = project.errors.full_messages.to_sentence
error_message = model_errors.presence || 'Project could not be updated!'
error(error_message)
end
def renaming_project_with_container_registry_tags?
new_path = params[:path]
......
......@@ -30,7 +30,9 @@ describe API::Settings, 'Settings' do
describe "PUT /application/settings" do
context "custom repository storage type set in the config" do
before do
storages = { 'custom' => 'tmp/tests/custom_repositories' }
# Add a possible storage to the config
storages = Gitlab.config.repositories.storages
.merge({ 'custom' => 'tmp/tests/custom_repositories' })
allow(Gitlab.config.repositories).to receive(:storages).and_return(storages)
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment