diff options
author | Drew Blessing <drew@gitlab.com> | 2016-08-02 22:46:43 -0600 |
---|---|---|
committer | Drew Blessing <drew@gitlab.com> | 2016-11-01 14:52:59 -0500 |
commit | af5322e90b47e830e7713482854ddf6450a0d8c1 (patch) | |
tree | aa15e96de4e970a83323da613b4b50eef367e703 /spec | |
parent | f73f09b1e079e2c1e1793878437f00731af5e177 (diff) | |
download | gitlab-ce-af5322e90b47e830e7713482854ddf6450a0d8c1.tar.gz |
Add Rake task to create/repair GitLab Shell hooks symlinks
Diffstat (limited to 'spec')
-rw-r--r-- | spec/rake_helper.rb | 19 | ||||
-rw-r--r-- | spec/support/rake_helpers.rb | 10 | ||||
-rw-r--r-- | spec/tasks/gitlab/shell_rake_spec.rb | 26 |
3 files changed, 55 insertions, 0 deletions
diff --git a/spec/rake_helper.rb b/spec/rake_helper.rb new file mode 100644 index 00000000000..9b5b4bf9fea --- /dev/null +++ b/spec/rake_helper.rb @@ -0,0 +1,19 @@ +require 'spec_helper' +require 'rake' + +RSpec.configure do |config| + config.include RakeHelpers + + # Redirect stdout so specs don't have so much noise + config.before(:all) do + $stdout = StringIO.new + + Rake.application.rake_require 'tasks/gitlab/task_helpers' + Rake::Task.define_task :environment + end + + # Reset stdout + config.after(:all) do + $stdout = STDOUT + end +end diff --git a/spec/support/rake_helpers.rb b/spec/support/rake_helpers.rb new file mode 100644 index 00000000000..52d80c69835 --- /dev/null +++ b/spec/support/rake_helpers.rb @@ -0,0 +1,10 @@ +module RakeHelpers + def run_rake_task(task_name) + Rake::Task[task_name].reenable + Rake.application.invoke_task task_name + end + + def stub_warn_user_is_not_gitlab + allow_any_instance_of(Object).to receive(:warn_user_is_not_gitlab) + end +end diff --git a/spec/tasks/gitlab/shell_rake_spec.rb b/spec/tasks/gitlab/shell_rake_spec.rb new file mode 100644 index 00000000000..226d34fe2c9 --- /dev/null +++ b/spec/tasks/gitlab/shell_rake_spec.rb @@ -0,0 +1,26 @@ +require 'rake_helper' + +describe 'gitlab:shell rake tasks' do + before do + Rake.application.rake_require 'tasks/gitlab/shell' + + stub_warn_user_is_not_gitlab + end + + describe 'install task' do + it 'invokes create_hooks task' do + expect(Rake::Task['gitlab:shell:create_hooks']).to receive(:invoke) + + run_rake_task('gitlab:shell:install') + end + end + + describe 'create_hooks task' do + it 'calls gitlab-shell bin/create_hooks' do + expect_any_instance_of(Object).to receive(:system) + .with("#{Gitlab.config.gitlab_shell.path}/bin/create-hooks", *repository_storage_paths_args) + + run_rake_task('gitlab:shell:create_hooks') + end + end +end |