summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2019-04-11 09:32:02 +0000
committerDouwe Maan <douwe@gitlab.com>2019-04-11 09:32:02 +0000
commit79b0bf2a9fa226e5b1b03252bf28e41f2cb7f184 (patch)
tree22ec24a4ea29c1eecc4abf35c75813ab9ae4e46b
parent474f8dab740793d70756bec8b4d3b2e3a487633f (diff)
parent22c1c9805b00ebc3bbb48fabba49cf2ba3e696e0 (diff)
downloadgitlab-ce-79b0bf2a9fa226e5b1b03252bf28e41f2cb7f184.tar.gz
Merge branch '60278-fix-development-seed' into 'master'
Fix ApplicationSetting development seed Closes #60278 See merge request gitlab-org/gitlab-ce!27213
-rw-r--r--app/models/application_setting.rb4
-rw-r--r--app/services/projects/create_service.rb4
-rw-r--r--db/fixtures/development/02_application_settings.rb2
3 files changed, 6 insertions, 4 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index 21a97c8d773..eb6ddaac871 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -259,7 +259,9 @@ class ApplicationSetting < ApplicationRecord
after_commit :expire_performance_bar_allowed_user_ids_cache, if: -> { previous_changes.key?('performance_bar_allowed_group_id') }
def self.create_from_defaults
- super
+ transaction(requires_new: true) do
+ super
+ end
rescue ActiveRecord::RecordNotUnique
# We already have an ApplicationSetting record, so just return it.
current_without_cache
diff --git a/app/services/projects/create_service.rb b/app/services/projects/create_service.rb
index 3723c5ef7d7..4ea40e3c8ce 100644
--- a/app/services/projects/create_service.rb
+++ b/app/services/projects/create_service.rb
@@ -159,8 +159,8 @@ module Projects
log_message << " Project ID: #{@project.id}" if @project&.id
Rails.logger.error(log_message)
- if @project
- @project.import_state.mark_as_failed(message) if @project.persisted? && @project.import?
+ if @project && @project.persisted? && @project.import_state
+ @project.import_state.mark_as_failed(message)
end
@project
diff --git a/db/fixtures/development/02_application_settings.rb b/db/fixtures/development/02_application_settings.rb
index d604f0be3cd..7cdc8e40b69 100644
--- a/db/fixtures/development/02_application_settings.rb
+++ b/db/fixtures/development/02_application_settings.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
puts "Creating the default ApplicationSetting record.".color(:green)
-Gitlab::CurrentSettings.current_application_settings
+ApplicationSetting.create_from_defaults
# Details https://gitlab.com/gitlab-org/gitlab-ce/issues/46241
puts "Enable hashed storage for every new projects.".color(:green)