summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-04-07 00:23:02 -0700
committerStan Hu <stanhu@gmail.com>2016-04-07 00:29:01 -0700
commit27b9f64efbbce9d74eeb9c4ae340506242c474cb (patch)
treea83ef198b7127053c8920a39d12600e2a3200c73
parent8f0945311b8f5fe30b0b57739ee9f3262499f375 (diff)
downloadgitlab-ce-27b9f64efbbce9d74eeb9c4ae340506242c474cb.tar.gz
Expire caches after project creation to ensure a consistent state
Closes #14961
-rw-r--r--app/models/repository.rb2
-rw-r--r--spec/models/repository_spec.rb13
2 files changed, 15 insertions, 0 deletions
diff --git a/app/models/repository.rb b/app/models/repository.rb
index a8e826c9cbf..8dead3a5884 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -331,6 +331,8 @@ class Repository
# Runs code after a repository has been created.
def after_create
expire_exists_cache
+ expire_root_ref_cache
+ expire_emptiness_caches
end
# Runs code just before a repository is deleted.
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index f517f325c03..4e49c413f23 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -670,6 +670,19 @@ describe Repository, models: true do
repository.after_create
end
+
+ it 'flushes the root ref cache' do
+ expect(repository).to receive(:expire_root_ref_cache)
+
+ repository.after_create
+ end
+
+ it 'flushes the emptiness caches' do
+ expect(repository).to receive(:expire_emptiness_caches)
+
+ repository.after_create
+ end
+
end
describe "#main_language" do