summaryrefslogtreecommitdiff
path: root/spec/gitlab_shell_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/gitlab_shell_spec.rb')
-rw-r--r--spec/gitlab_shell_spec.rb37
1 files changed, 35 insertions, 2 deletions
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index 44dca6d..4741303 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -48,6 +48,14 @@ describe GitlabShell do
its(:repo_name) { should == 'dmitriy.zaporozhets/gitlab-ci.git' }
its(:git_cmd) { should == 'git-upload-pack' }
end
+
+ context 'with an invalid number of arguments' do
+ before { ssh_cmd 'foobar' }
+
+ it "should raise an DisallowedCommandError" do
+ expect { subject.send :parse_cmd }.to raise_error(GitlabShell::DisallowedCommandError)
+ end
+ end
end
describe :exec do
@@ -60,7 +68,7 @@ describe GitlabShell do
end
it "should execute the command" do
- subject.should_receive(:exec_cmd).with("git-upload-pack #{File.join(repository_path, 'gitlab-ci.git')}")
+ subject.should_receive(:exec_cmd).with("git-upload-pack", File.join(repository_path, 'gitlab-ci.git'))
end
it "should set the GL_ID environment variable" do
@@ -89,7 +97,7 @@ describe GitlabShell do
end
it "should execute the command" do
- subject.should_receive(:exec_cmd).with("git-receive-pack #{File.join(repository_path, 'gitlab-ci.git')}")
+ subject.should_receive(:exec_cmd).with("git-receive-pack", File.join(repository_path, 'gitlab-ci.git'))
end
it "should log the command execution" do
@@ -145,6 +153,31 @@ describe GitlabShell do
end
end
+ describe :exec_cmd do
+ let(:shell) { GitlabShell.new }
+ before { Kernel.stub!(:exec) }
+
+ it "uses Kernel::exec method" do
+ Kernel.should_receive(:exec).with(kind_of(Hash), 1, unsetenv_others: true).once
+ shell.send :exec_cmd, 1
+ end
+ end
+
+ describe :api do
+ let(:shell) { GitlabShell.new }
+ subject { shell.send :api }
+
+ it { should be_a(GitlabNet) }
+ end
+
+ describe :escape_path do
+ let(:shell) { GitlabShell.new }
+ before { File.stub(:absolute_path) { 'y' } }
+ subject { -> { shell.send(:escape_path, 'z') } }
+
+ it { should raise_error(SystemExit, "Wrong repository path") }
+ end
+
def ssh_cmd(cmd)
ENV['SSH_ORIGINAL_COMMAND'] = cmd
end