diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 15:09:17 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-12 15:09:17 +0300 |
commit | cd52759ee33051b8ad7b88b02ba7954e4fad7018 (patch) | |
tree | f1096c68e457aef7f5201acd16e4a751ff538026 /spec/workers | |
parent | 18f7828977b74bf6e5153594a098ef90e773b3b7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/workers')
-rw-r--r-- | spec/workers/authorized_keys_worker_spec.rb | 55 | ||||
-rw-r--r-- | spec/workers/gitlab_shell_worker_spec.rb | 33 |
2 files changed, 83 insertions, 5 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 diff --git a/spec/workers/gitlab_shell_worker_spec.rb b/spec/workers/gitlab_shell_worker_spec.rb index 5dedf5be9fa..f5884e5e8f8 100644 --- a/spec/workers/gitlab_shell_worker_spec.rb +++ b/spec/workers/gitlab_shell_worker_spec.rb @@ -5,12 +5,35 @@ require 'spec_helper' describe GitlabShellWorker do let(:worker) { described_class.new } - describe '#perform with add_key' do - it 'calls add_key on Gitlab::Shell' do - expect_next_instance_of(Gitlab::Shell) do |instance| - expect(instance).to receive(:add_key).with('foo', 'bar') + 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') end - worker.perform(:add_key, 'foo', 'bar') end end end |