2019-03-30 03:15:48 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-26 17:40:08 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 11:08:50 -04:00
|
|
|
RSpec.describe GitlabShellWorker do
|
2017-06-26 17:40:08 -04:00
|
|
|
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
|
|
|
|
|
2020-03-23 14:09:25 -04:00
|
|
|
worker.perform('add_key', 'foo', 'bar')
|
2020-03-12 08:09:17 -04:00
|
|
|
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
|
|
|
|
|
2020-03-23 14:09:25 -04:00
|
|
|
worker.perform('remove_key', 'foo', 'bar')
|
2020-03-12 08:09:17 -04:00
|
|
|
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
|
|
|
|
|
2020-03-23 14:09:25 -04:00
|
|
|
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
|