diff options
| author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-01 11:48:08 +0200 |
|---|---|---|
| committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-10-01 11:48:08 +0200 |
| commit | 33c8d4879f34402876980d40716a64ae6f888347 (patch) | |
| tree | 55d7a5a844c7e3cec5ff6ad0203e5383b5e0204a /spec | |
| parent | 979a6df4755a114e38cd1825be40cb07225f1fb4 (diff) | |
| parent | 57bc57298c64f40a0a851e474b3e6de91a551ec5 (diff) | |
| download | gitlab-shell-33c8d4879f34402876980d40716a64ae6f888347.tar.gz | |
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-shell into no-init-on-gcryptsetup
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/gitlab_projects_spec.rb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spec/gitlab_projects_spec.rb b/spec/gitlab_projects_spec.rb index e8875b6..50af42f 100644 --- a/spec/gitlab_projects_spec.rb +++ b/spec/gitlab_projects_spec.rb @@ -12,6 +12,51 @@ describe GitlabProjects do FileUtils.rm_rf(tmp_repos_path) end + describe :create_hooks do + let(:repo_path) { File.join(tmp_repos_path, 'hook-test.git') } + let(:hooks_dir) { File.join(repo_path, 'hooks') } + let(:target_hooks_dir) { File.join(ROOT_PATH, 'hooks') } + let(:existing_target) { File.join(repo_path, 'foobar') } + + before do + FileUtils.rm_rf(repo_path) + FileUtils.mkdir_p(repo_path) + end + + context 'hooks is a directory' do + let(:existing_file) { File.join(hooks_dir, 'my-file') } + + before do + FileUtils.mkdir_p(hooks_dir) + FileUtils.touch(existing_file) + GitlabProjects.create_hooks(repo_path) + end + + it { File.readlink(hooks_dir).should == target_hooks_dir } + it { Dir[File.join(repo_path, "hooks.old.*/my-file")].count.should == 1 } + end + + context 'hooks is a valid symlink' do + before do + FileUtils.mkdir_p existing_target + File.symlink(existing_target, hooks_dir) + GitlabProjects.create_hooks(repo_path) + end + + it { File.readlink(hooks_dir).should == target_hooks_dir } + end + + context 'hooks is a broken symlink' do + before do + FileUtils.rm_f(existing_target) + File.symlink(existing_target, hooks_dir) + GitlabProjects.create_hooks(repo_path) + end + + it { File.readlink(hooks_dir).should == target_hooks_dir } + end + end + describe :initialize do before do argv('add-project', repo_name) |
