From 95a270c87104e1225d4c29a54611f5e4f7a76b56 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Tue, 8 Aug 2017 11:53:52 +0200 Subject: Fix repository reloading in some specs --- app/models/project.rb | 4 ++++ app/models/storage/hashed_project.rb | 4 ++-- app/models/storage/legacy_project.rb | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index 5f510412015..b84d06fef1e 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -478,6 +478,10 @@ class Project < ActiveRecord::Base @repository ||= Repository.new(full_path, self, disk_path: disk_path) end + def reload_repository! + @repository = nil + end + def container_registry_url if Gitlab.config.registry.enabled "#{Gitlab.config.registry.host_port}/#{full_path.downcase}" diff --git a/app/models/storage/hashed_project.rb b/app/models/storage/hashed_project.rb index 364794a4eef..91f74b084b6 100644 --- a/app/models/storage/hashed_project.rb +++ b/app/models/storage/hashed_project.rb @@ -47,11 +47,11 @@ module Storage project.send_move_instructions(old_path_with_namespace) - @old_path_with_namespace = old_path_with_namespace + project.old_path_with_namespace = old_path_with_namespace SystemHooksService.new.execute_hooks_for(project, :rename) - @repository = nil + project.reload_repository! rescue => e Rails.logger.error "Exception renaming #{old_path_with_namespace} -> #{new_path_with_namespace}: #{e}" # Returning false does not rollback after_* transaction but gives diff --git a/app/models/storage/legacy_project.rb b/app/models/storage/legacy_project.rb index 57c340075ba..b7b073ad077 100644 --- a/app/models/storage/legacy_project.rb +++ b/app/models/storage/legacy_project.rb @@ -52,11 +52,11 @@ module Storage project.send_move_instructions(old_path_with_namespace) project.expires_full_path_cache - @old_path_with_namespace = old_path_with_namespace + project.old_path_with_namespace = old_path_with_namespace SystemHooksService.new.execute_hooks_for(project, :rename) - @repository = nil + project.reload_repository! rescue => e Rails.logger.error "Exception renaming #{old_path_with_namespace} -> #{new_path_with_namespace}: #{e}" # Returning false does not rollback after_* transaction but gives -- cgit v1.2.1