summaryrefslogtreecommitdiff
path: root/spec/gitlab_keys_spec.rb
diff options
context:
space:
mode:
authorJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-02 18:52:51 +0100
committerJacob Vosmaer <contact@jacobvosmaer.nl>2013-11-02 18:52:51 +0100
commit633042fd189f0e0ac62086a1e58ea0e3f89b8ff2 (patch)
tree4244c05b447054951050f61582b827b232a2bc27 /spec/gitlab_keys_spec.rb
parent261cb1fe7c946e034a5f43a03e9da86476eca8f2 (diff)
downloadgitlab-shell-633042fd189f0e0ac62086a1e58ea0e3f89b8ff2.tar.gz
Remove sed invocation from GitlabKeys
Diffstat (limited to 'spec/gitlab_keys_spec.rb')
-rw-r--r--spec/gitlab_keys_spec.rb15
1 files changed, 10 insertions, 5 deletions
diff --git a/spec/gitlab_keys_spec.rb b/spec/gitlab_keys_spec.rb
index cbe09bd..3688a96 100644
--- a/spec/gitlab_keys_spec.rb
+++ b/spec/gitlab_keys_spec.rb
@@ -34,14 +34,15 @@ describe GitlabKeys do
describe :rm_key do
let(:gitlab_keys) { build_gitlab_keys('rm-key', 'key-741', 'ssh-rsa AAAAB3NzaDAxx2E') }
- let(:temp_file) { mock(:temp_file, path: 'tmp_path') }
- before { Tempfile.should_receive(:open).and_yield(temp_file) }
it "should receive valid cmd" do
- auth_file = GitlabConfig.new.auth_file
- valid_cmd = "sed '/shell key-741\"/d' #{auth_file} > tmp_path && mv tmp_path #{auth_file}"
- gitlab_keys.should_receive(:system).with(valid_cmd)
+ FileUtils.mkdir_p(File.dirname(tmp_authorized_keys_path))
+ open(tmp_authorized_keys_path, 'w') do |auth_file|
+ auth_file.puts ['first key', '/bin/gitlab-shell key-741"', 'third key']
+ end
+ gitlab_keys.stub(auth_file: tmp_authorized_keys_path)
gitlab_keys.send :rm_key
+ File.read(tmp_authorized_keys_path).should == "first key\nthird key\n"
end
it "should log an rm-key event" do
@@ -87,4 +88,8 @@ describe GitlabKeys do
ARGV[i] = arg
end
end
+
+ def tmp_authorized_keys_path
+ File.join(ROOT_PATH, 'tmp', 'authorized_keys')
+ end
end