2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-26 17:40:08 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe GitlabShellWorker do
|
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
2020-03-12 08:09:17 -04:00
|
|
|
describe '#perform' do
|
|
|
|
describe '#add_key' do
|
|
|
|
it 'delegates to Gitlab::AuthorizedKeys' do
|
|
|
|
expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance|
|
|
|
|
expect(instance).to receive(:add_key).with('foo', 'bar')
|
|
|
|
end
|
|
|
|
|
|
|
|
worker.perform(:add_key, 'foo', 'bar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#remove_key' do
|
|
|
|
it 'delegates to Gitlab::AuthorizedKeys' do
|
|
|
|
expect_next_instance_of(Gitlab::AuthorizedKeys) do |instance|
|
|
|
|
expect(instance).to receive(:remove_key).with('foo', 'bar')
|
|
|
|
end
|
|
|
|
|
|
|
|
worker.perform(:remove_key, 'foo', 'bar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe 'all other commands' do
|
|
|
|
it 'delegates them to Gitlab::Shell' do
|
|
|
|
expect_next_instance_of(Gitlab::Shell) do |instance|
|
|
|
|
expect(instance).to receive(:foo).with('bar', 'baz')
|
|
|
|
end
|
|
|
|
|
|
|
|
worker.perform(:foo, 'bar', 'baz')
|
2020-01-17 16:08:29 -05:00
|
|
|
end
|
2017-06-26 17:40:08 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|