diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 12:09:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 12:09:17 +0000 |
commit | cd52759ee33051b8ad7b88b02ba7954e4fad7018 (patch) | |
tree | f1096c68e457aef7f5201acd16e4a751ff538026 /spec/workers/authorized_keys_worker_spec.rb | |
parent | 18f7828977b74bf6e5153594a098ef90e773b3b7 (diff) | |
download | gitlab-ce-cd52759ee33051b8ad7b88b02ba7954e4fad7018.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers/authorized_keys_worker_spec.rb')
-rw-r--r-- | spec/workers/authorized_keys_worker_spec.rb | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/spec/workers/authorized_keys_worker_spec.rb b/spec/workers/authorized_keys_worker_spec.rb new file mode 100644 index 00000000000..2aaa6fb2ddf --- /dev/null +++ b/spec/workers/authorized_keys_worker_spec.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe AuthorizedKeysWorker do + let(:worker) { described_class.new } + + describe '#perform' do + context 'authorized_keys is enabled' do + before do + stub_application_setting(authorized_keys_enabled: true) + end + + 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 'does nothing' do + expect(Gitlab::AuthorizedKeys).not_to receive(:new) + + worker.perform(:foo, 'bar', 'baz') + end + end + end + + context 'authorized_keys is disabled' do + before do + stub_application_setting(authorized_keys_enabled: false) + end + + it 'does nothing' do + expect(Gitlab::AuthorizedKeys).not_to receive(:new) + + worker.perform(:add_key, 'foo', 'bar') + end + end + end +end |