Commit 590e1b4b authored by Yorick Peterse's avatar Yorick Peterse

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.
parent 4ec035b4
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment