summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2019-02-27 10:58:21 +0000
committerDouwe Maan <douwe@gitlab.com>2019-02-27 10:58:21 +0000
commit078f11a6b9c0197a3cfde6b3658ca268097e315c (patch)
treea2253cf873eb585e2a2812ff584cd2e748ed6e02 /spec
parent1b10b77babf008daf337ff194f10508935a8c8a2 (diff)
downloadgitlab-ce-078f11a6b9c0197a3cfde6b3658ca268097e315c.tar.gz
Prepare test suite for switch to Gitaly-embedded Git hooks
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/git/repository_spec.rb4
-rw-r--r--spec/lib/gitlab/shell_spec.rb1
-rw-r--r--spec/support/helpers/test_env.rb12
-rw-r--r--spec/tasks/gitlab/shell_rake_spec.rb2
4 files changed, 11 insertions, 8 deletions
diff --git a/spec/lib/gitlab/git/repository_spec.rb b/spec/lib/gitlab/git/repository_spec.rb
index b3a728c139e..e3dd02f1478 100644
--- a/spec/lib/gitlab/git/repository_spec.rb
+++ b/spec/lib/gitlab/git/repository_spec.rb
@@ -31,7 +31,7 @@ describe Gitlab::Git::Repository, :seed_helper do
describe '.create_hooks' do
let(:repo_path) { File.join(storage_path, 'hook-test.git') }
let(:hooks_dir) { File.join(repo_path, 'hooks') }
- let(:target_hooks_dir) { Gitlab.config.gitlab_shell.hooks_path }
+ let(:target_hooks_dir) { Gitlab::Shell.new.hooks_path }
let(:existing_target) { File.join(repo_path, 'foobar') }
before do
@@ -1945,7 +1945,7 @@ describe Gitlab::Git::Repository, :seed_helper do
imported_repo.create_from_bundle(valid_bundle_path)
hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
- expect(File.readlink(hooks_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
+ expect(File.readlink(hooks_path)).to eq(Gitlab::Shell.new.hooks_path)
end
it 'raises an error if the bundle is an attempted malicious payload' do
diff --git a/spec/lib/gitlab/shell_spec.rb b/spec/lib/gitlab/shell_spec.rb
index 033e1bf81a1..d6aadf0f7de 100644
--- a/spec/lib/gitlab/shell_spec.rb
+++ b/spec/lib/gitlab/shell_spec.rb
@@ -393,7 +393,6 @@ describe Gitlab::Shell do
before do
allow(Gitlab.config.gitlab_shell).to receive(:path).and_return(gitlab_shell_path)
- allow(Gitlab.config.gitlab_shell).to receive(:hooks_path).and_return(gitlab_shell_hooks_path)
allow(Gitlab.config.gitlab_shell).to receive(:git_timeout).and_return(800)
end
diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb
index 06bcf4f8013..80a22134021 100644
--- a/spec/support/helpers/test_env.rb
+++ b/spec/support/helpers/test_env.rb
@@ -147,12 +147,15 @@ module TestEnv
version: Gitlab::Shell.version_required,
task: 'gitlab:shell:install')
- create_fake_git_hooks
+ # gitlab-shell hooks don't work in our test environment because they try to make internal API calls
+ sabotage_gitlab_shell_hooks
end
- def create_fake_git_hooks
- # gitlab-shell hooks don't work in our test environment because they try to make internal API calls
- hooks_dir = File.join(Gitlab.config.gitlab_shell.path, 'hooks')
+ def sabotage_gitlab_shell_hooks
+ create_fake_git_hooks(Gitlab::Shell.new.hooks_path)
+ end
+
+ def create_fake_git_hooks(hooks_dir)
%w[pre-receive post-receive update].each do |hook|
File.open(File.join(hooks_dir, hook), 'w', 0755) { |f| f.puts '#!/bin/sh' }
end
@@ -169,6 +172,7 @@ module TestEnv
task: "gitlab:gitaly:install[#{install_gitaly_args}]") do
Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, { 'default' => repos_path }, force: true)
+ create_fake_git_hooks(File.join(gitaly_dir, 'ruby/git-hooks'))
start_gitaly(gitaly_dir)
end
end
diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb
index 0ed5d3e27b9..a9d14070177 100644
--- a/spec/tasks/gitlab/shell_rake_spec.rb
+++ b/spec/tasks/gitlab/shell_rake_spec.rb
@@ -8,7 +8,7 @@ describe 'gitlab:shell rake tasks' do
end
after do
- TestEnv.create_fake_git_hooks
+ TestEnv.sabotage_gitlab_shell_hooks
end
describe 'install task' do