From 68a4c98f5074bd34f0178f2f967153c8d5c71237 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 18 Mar 2016 15:31:19 +0100 Subject: Cache output of Repository#exists? This caches the output of Repository#exists? in Redis while making sure it's flushed properly when creating new repositories, deleting them, etc. For the ProjectWiki tests to work I had to make ProjectWiki#create_repo! public as testing private methods in RSpec is a bit of a pain. --- app/models/project_wiki.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app/models/project_wiki.rb') diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index 59b1b86d1fb..7c1a61bb0bf 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -123,23 +123,27 @@ class ProjectWiki end def repository - Repository.new(path_with_namespace, @project) + @repository ||= Repository.new(path_with_namespace, @project) end def default_branch wiki.class.default_ref end - private - def create_repo! if init_repo(path_with_namespace) - Gollum::Wiki.new(path_to_repo) + wiki = Gollum::Wiki.new(path_to_repo) else raise CouldNotCreateWikiError end + + repository.after_create + + wiki end + private + def init_repo(path_with_namespace) gitlab_shell.add_repository(path_with_namespace) end -- cgit v1.2.1