Call after_create_branch in Repository#add_branch

This ensures the right caches are flushed when adding a branch via the
UI, instead of only flushing this one random cache.
This commit is contained in:
Yorick Peterse 2016-03-08 18:04:00 +01:00
parent 4ec035b488
commit 590e1b4b21
2 changed files with 8 additions and 1 deletions

View file

@ -133,7 +133,7 @@ class Repository
rugged.branches.create(branch_name, target)
end
expire_branches_cache
after_create_branch
find_branch(branch_name)
end
@ -356,6 +356,7 @@ class Repository
# Runs code after a new branch has been created.
def after_create_branch
expire_branches_cache
expire_has_visible_content_cache
expire_branch_count_cache
end

View file

@ -148,6 +148,12 @@ describe Repository, models: true do
expect(branch.name).to eq('new_feature')
end
it 'calls the after_create_branch hook' do
expect(repository).to receive(:after_create_branch)
repository.add_branch(user, 'new_feature', 'master')
end
end
context 'when pre hooks failed' do