2019-03-30 07:15:48 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-26 21:40:08 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 15:08:50 +00:00
|
|
|
RSpec.describe GitlabShellWorker do
|
2017-06-26 21:40:08 +00:00
|
|
|
let(:worker) { described_class.new }
|
|
|
|
|
2020-03-12 12:09:17 +00: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 18:09:25 +00:00
|
|
|
worker.perform('add_key', 'foo', 'bar')
|
2020-03-12 12:09:17 +00: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 18:09:25 +00:00
|
|
|
worker.perform('remove_key', 'foo', 'bar')
|
2020-03-12 12:09:17 +00: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 18:09:25 +00:00
|
|
|
worker.perform('foo', 'bar', 'baz')
|
2020-01-17 21:08:29 +00:00
|
|
|
end
|
2017-06-26 21:40:08 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|