summaryrefslogtreecommitdiff
path: root/spec/gitlab_shell_spec.rb
diff options
context:
space:
mode:
authorChristian Höltje <choltje@us.ibm.com>2013-03-15 13:10:47 -0400
committerChristian Höltje <choltje@us.ibm.com>2013-03-15 13:10:47 -0400
commitbc770be542009af7863ba6d4b33935836779aa81 (patch)
treeb5f07ce9e9201f8bcb17c79e47dee047298cf0a1 /spec/gitlab_shell_spec.rb
parente794bdf37503360094e6414bb931dbf135e636ca (diff)
downloadgitlab-shell-bc770be542009af7863ba6d4b33935836779aa81.tar.gz
Verify GL_ID environment variable is set.
This also randomizes the key_id used in the tests.
Diffstat (limited to 'spec/gitlab_shell_spec.rb')
-rw-r--r--spec/gitlab_shell_spec.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/spec/gitlab_shell_spec.rb b/spec/gitlab_shell_spec.rb
index 2fa44a9..ef227ba 100644
--- a/spec/gitlab_shell_spec.rb
+++ b/spec/gitlab_shell_spec.rb
@@ -3,7 +3,7 @@ require_relative '../lib/gitlab_shell'
describe GitlabShell do
subject do
- ARGV[0] = 'key-56'
+ ARGV[0] = key_id
GitlabShell.new.tap do |shell|
shell.stub(exec_cmd: :exec_called)
shell.stub(api: api)
@@ -15,11 +15,12 @@ describe GitlabShell do
api.stub(allowed?: true)
end
end
+ let(:key_id) { "key-#{rand(100) + 100}" }
describe :initialize do
before { ssh_cmd 'git-receive-pack' }
- its(:key_id) { should == 'key-56' }
+ its(:key_id) { should == key_id }
its(:repos_path) { should == "/home/git/repositories" }
end
@@ -57,6 +58,10 @@ describe GitlabShell do
it "should execute the command" do
subject.should_receive(:exec_cmd).with("git-upload-pack /home/git/repositories/gitlab-ci.git")
end
+
+ it "should set the GL_ID environment variable" do
+ ENV.should_receive("[]=").with("GL_ID", key_id)
+ end
end
context 'git-receive-pack' do
@@ -90,7 +95,7 @@ describe GitlabShell do
after { subject.exec }
it "should call api.discover" do
- api.should_receive(:discover).with('key-56')
+ api.should_receive(:discover).with(key_id)
end
end
end
@@ -101,7 +106,7 @@ describe GitlabShell do
it "should call api.allowed?" do
api.should_receive(:allowed?).
- with('git-upload-pack', 'gitlab-ci.git', 'key-56', '_any')
+ with('git-upload-pack', 'gitlab-ci.git', key_id, '_any')
end
end