summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortiagonbotelho <tiagonbotelho@hotmail.com>2016-07-26 12:46:27 +0100
committertiagonbotelho <tiagonbotelho@hotmail.com>2016-07-26 19:29:27 +0100
commit64b0eccdb0c38980ba574b1d156271ebc3fb9124 (patch)
treeba8c0e6fc0bee3cdc1ee5e6df3323e60d06b0446
parente50bc796303ac6a2051df1685cf933f4b4a3e115 (diff)
downloadgitlab-ce-20025-empty-project-does-not-show-repository.tar.gz
when creating first file in project rspective caches are now expired and20025-empty-project-does-not-show-repository
implement tests to verify it and branch cache is always refreshed when new branch and make tests for it
-rw-r--r--CHANGELOG2
-rw-r--r--app/models/repository.rb6
-rw-r--r--spec/models/repository_spec.rb17
3 files changed, 19 insertions, 6 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 319eb54ec58..dda7e1671b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,9 +12,7 @@ v 8.11.0 (unreleased)
- Make fork counter always clickable. !5463 (winniehell)
- Remove `search_id` of labels dropdown filter to fix 'Missleading URI for labels in Merge Requests and Issues view'. !5368 (Scott Le)
- Load project invited groups and members eagerly in `ProjectTeam#fetch_members`
- - Make fork counter always clickable !5463 (winniehell)
- Page is now properly rendered after commiting the first file and creating the first branch
- - Load project invited groups and members eagerly in ProjectTeam#fetch_members
- Add GitLab Workhorse version to admin dashboard (Katarzyna Kobierska Ula Budziszewska)
- Add the `sprockets-es6` gem
- Multiple trigger variables show in separate lines (Katarzyna Kobierska Ula Budziszewska)
diff --git a/app/models/repository.rb b/app/models/repository.rb
index e43fab62b89..9fd8f5ec787 100644
--- a/app/models/repository.rb
+++ b/app/models/repository.rb
@@ -990,10 +990,8 @@ class Repository
rugged.references.create(ref, newrev)
# If repo was empty expire cache
- if was_empty
- after_create
- after_create_branch
- end
+ after_create if was_empty
+ after_create_branch
else
# Update head
current_head = find_branch(branch).target
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 42c6bfcd09d..5bc1bd9a930 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -447,6 +447,23 @@ describe Repository, models: true do
end
end
+ context 'when target branch is different from source branch' do
+ before do
+ allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, ''])
+ end
+
+ it 'expires branch cache' do
+ expect(repository).not_to receive(:expire_exists_cache)
+ expect(repository).not_to receive(:expire_root_ref_cache)
+ expect(repository).not_to receive(:expire_emptiness_caches)
+ expect(repository).to receive(:expire_branches_cache)
+ expect(repository).to receive(:expire_has_visible_content_cache)
+ expect(repository).to receive(:expire_branch_count_cache)
+
+ repository.commit_with_hooks(user, 'new-feature') { sample_commit.id }
+ end
+ end
+
context 'when repository is empty' do
before do
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, ''])