summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAlejandro Rodríguez <alejorro70@gmail.com>2018-01-10 13:34:31 -0300
committerAlejandro Rodríguez <alejorro70@gmail.com>2018-01-19 13:57:17 -0300
commit081a584a35eb44dafd77d212acd9317a7f1414ef (patch)
treef4b90c910e174a836a161c1cea6314de6f5dc040 /spec
parentfbcd5197ca6fa6d82f719b95779f28d6784946e4 (diff)
downloadgitlab-ce-081a584a35eb44dafd77d212acd9317a7f1414ef.tar.gz
Ensure hooks are deleted regardless of the project forking method
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/git/gitlab_projects_spec.rb3
-rw-r--r--spec/spec_helper.rb10
-rw-r--r--spec/support/project_forks_helper.rb4
3 files changed, 13 insertions, 4 deletions
diff --git a/spec/lib/gitlab/git/gitlab_projects_spec.rb b/spec/lib/gitlab/git/gitlab_projects_spec.rb
index 78e4fbca28e..f4b964e1ee9 100644
--- a/spec/lib/gitlab/git/gitlab_projects_spec.rb
+++ b/spec/lib/gitlab/git/gitlab_projects_spec.rb
@@ -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
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 6186fb92bad..85de0a14631 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -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
diff --git a/spec/support/project_forks_helper.rb b/spec/support/project_forks_helper.rb
index d6680735aa1..2c501a2a27c 100644
--- a/spec/support/project_forks_helper.rb
+++ b/spec/support/project_forks_helper.rb
@@ -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