Ensure hooks are deleted regardless of the project forking method
This commit is contained in:
parent
fbcd5197ca
commit
081a584a35
3 changed files with 13 additions and 4 deletions
|
@ -219,6 +219,9 @@ describe Gitlab::Git::GitlabProjects do
|
|||
|
||||
before do
|
||||
FileUtils.mkdir_p(dest_repos_path)
|
||||
|
||||
# Undo spec_helper stub that deletes hooks
|
||||
allow_any_instance_of(described_class).to receive(:fork_repository).and_call_original
|
||||
end
|
||||
|
||||
after do
|
||||
|
|
|
@ -100,6 +100,16 @@ RSpec.configure do |config|
|
|||
config.before(:example) do
|
||||
# Skip pre-receive hook check so we can use the web editor and merge.
|
||||
allow_any_instance_of(Gitlab::Git::Hook).to receive(:trigger).and_return([true, nil])
|
||||
|
||||
allow_any_instance_of(Gitlab::Git::GitlabProjects).to receive(:fork_repository).and_wrap_original do |m, *args|
|
||||
m.call(*args)
|
||||
|
||||
shard_path, repository_relative_path = args
|
||||
# We can't leave the hooks in place after a fork, as those would fail in tests
|
||||
# The "internal" API is not available
|
||||
FileUtils.rm_rf(File.join(shard_path, repository_relative_path, 'hooks'))
|
||||
end
|
||||
|
||||
# Enable all features by default for testing
|
||||
allow(Feature).to receive(:enabled?) { true }
|
||||
end
|
||||
|
|
|
@ -38,10 +38,6 @@ module ProjectForksHelper
|
|||
# so we have to explicitely call this method to clear the @exists variable.
|
||||
# of the instance we're returning here.
|
||||
forked_project.repository.after_import
|
||||
|
||||
# We can't leave the hooks in place after a fork, as those would fail in tests
|
||||
# The "internal" API is not available
|
||||
FileUtils.rm_rf("#{forked_project.repository.path}/hooks")
|
||||
end
|
||||
|
||||
forked_project
|
||||
|
|
Loading…
Reference in a new issue