diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-05 09:52:10 +0200 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2013-02-05 09:52:10 +0200 |
commit | ea6ea902bea6857d2a0dbdf6d5492105a527d276 (patch) | |
tree | 7e49eae43ce42b10c3df61ed7ae8e63884700523 /spec/gitlab_shell_spec.rb | |
parent | 8d37428444f255a79ed99cb7726977b7195c6ebb (diff) | |
download | gitlab-shell-ea6ea902bea6857d2a0dbdf6d5492105a527d276.tar.gz |
More tests
Diffstat (limited to 'spec/gitlab_shell_spec.rb')
-rw-r--r-- | spec/gitlab_shell_spec.rb | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb index 1132e81..fa46fb5 100644 --- a/spec/gitlab_shell_spec.rb +++ b/spec/gitlab_shell_spec.rb @@ -5,7 +5,7 @@ describe GitlabShell do describe :initialize do before do - ENV['SSH_ORIGINAL_COMMAND'] = 'git-receive-pack' + ssh_cmd 'git-receive-pack' ARGV[0] = 'dzaporozhets' @shell = GitlabShell.new end @@ -13,4 +13,59 @@ describe GitlabShell do it { @shell.username.should == 'dzaporozhets' } it { @shell.repos_path.should == "/home/git/repositories" } end + + describe :parse_cmd do + context 'w/o namespace' do + before do + ssh_cmd 'git-upload-pack gitlab-ci.git' + @shell = GitlabShell.new + @shell.send :parse_cmd + end + + it { @shell.repo_name.should == 'gitlab-ci.git' } + it { @shell.git_cmd.should == 'git-upload-pack' } + end + + context 'namespace' do + before do + ssh_cmd 'git-upload-pack dmitriy.zaporozhets/gitlab-ci.git' + @shell = GitlabShell.new + @shell.send :parse_cmd + end + + it { @shell.repo_name.should == 'dmitriy.zaporozhets/gitlab-ci.git' } + it { @shell.git_cmd.should == 'git-upload-pack' } + end + end + + describe :exec do + context 'git-upload-pack' do + before do + ssh_cmd 'git-upload-pack gitlab-ci.git' + stubbed_shell + end + + it { @shell.exec.should be_true } + end + + context 'git-receive-pack' do + before do + ssh_cmd 'git-receive-pack gitlab-ci.git' + stubbed_shell + end + + it { @shell.exec.should be_true } + end + end + + def ssh_cmd(cmd) + ENV['SSH_ORIGINAL_COMMAND'] = cmd + end + + def stubbed_shell + ARGV[0] = 'dzaporozhets' + @shell = GitlabShell.new + @shell.stub(validate_access: true) + @shell.stub(process_cmd: true) + end end |