summaryrefslogtreecommitdiff
path: root/spec/gitlab_keys_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-10 09:02:34 -0700
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-06-10 09:02:34 -0700
commit79c58482962bd7ddd4979a4afcd178f697fe84fa (patch)
treeb39538ed8086aa229ee68dddfd9436d0dcab65c0 /spec/gitlab_keys_spec.rb
parent45881f17d06c860c8fe6a0b0441a847a63b75783 (diff)
parent45b3a3a7cda1296682a2054abf89c95a55c78f0f (diff)
downloadgitlab-shell-79c58482962bd7ddd4979a4afcd178f697fe84fa.tar.gz
Merge pull request #56 from smashwilson/36-logger
Logger
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r--spec/gitlab_keys_spec.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index f04d506..09f5872 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -2,6 +2,10 @@ require_relative 'spec_helper'
require_relative '../lib/gitlab_keys'
describe GitlabKeys do
+ before do
+ $logger = double('logger').as_null_object
+ end
+
describe :initialize do
let(:gitlab_keys) { build_gitlab_keys('add-key', 'key-741', 'ssh-rsa AAAAB3NzaDAxx2E') }
@@ -18,6 +22,11 @@ describe GitlabKeys do
gitlab_keys.should_receive(:system).with(valid_cmd)
gitlab_keys.send :add_key
end
+
+ it "should log an add-key event" do
+ $logger.should_receive(:info).with('Adding key key-741 => "ssh-rsa AAAAB3NzaDAxx2E"')
+ gitlab_keys.send :add_key
+ end
end
describe :rm_key do
@@ -28,6 +37,11 @@ describe GitlabKeys do
gitlab_keys.should_receive(:system).with(valid_cmd)
gitlab_keys.send :rm_key
end
+
+ it "should log an rm-key event" do
+ $logger.should_receive(:info).with('Removing key key-741')
+ gitlab_keys.send :rm_key
+ end
end
describe :exec do
@@ -48,6 +62,13 @@ describe GitlabKeys do
gitlab_keys.should_receive(:puts).with('not allowed')
gitlab_keys.exec
end
+
+ it 'should log a warning on unknown commands' do
+ gitlab_keys = build_gitlab_keys('nooope')
+ gitlab_keys.stub(puts: nil)
+ $logger.should_receive(:warn).with('Attempt to execute invalid gitlab-keys command "nooope".')
+ gitlab_keys.exec
+ end
end
def build_gitlab_keys(*args)