2019-07-07 11:18:12 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
RSpec.describe GitlabShellWorker, :sidekiq_inline, feature_category: :source_code_management do
|
2020-04-08 14:13:33 +05:30
|
|
|
describe '#perform' do
|
2023-01-13 00:05:48 +05:30
|
|
|
Gitlab::Shell::PERMITTED_ACTIONS.each do |action|
|
|
|
|
describe "with the #{action} action" do
|
|
|
|
it 'forwards the message to Gitlab::Shell' do
|
|
|
|
expect_next_instance_of(Gitlab::Shell) do |instance|
|
|
|
|
expect(instance).to respond_to(action)
|
|
|
|
expect(instance).to receive(action).with('foo', 'bar')
|
|
|
|
end
|
|
|
|
|
|
|
|
described_class.perform_async(action, 'foo', 'bar')
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
describe 'all other commands' do
|
2023-03-04 22:38:38 +05:30
|
|
|
it 'raises ArgumentError' do
|
|
|
|
allow_next_instance_of(described_class) do |job_instance|
|
|
|
|
expect(job_instance).not_to receive(:gitlab_shell)
|
2020-04-08 14:13:33 +05:30
|
|
|
end
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
expect { described_class.perform_async('foo', 'bar', 'baz') }
|
|
|
|
.to raise_error(ArgumentError, 'foo not allowed for GitlabShellWorker')
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|