diff options
author | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-11-07 13:33:42 +0100 |
---|---|---|
committer | Bob Van Landuyt <bob@vanlanduyt.co> | 2018-11-07 16:27:55 +0100 |
commit | c85a19f920da1b544bbfae344145503c25e71048 (patch) | |
tree | 8acaf8e1b6cac9e71dbf545e8cf1443d03931280 /spec | |
parent | 6fbdc5ed5224154b89cf351e11a8f9db48e6d7f0 (diff) | |
download | gitlab-ce-c85a19f920da1b544bbfae344145503c25e71048.tar.gz |
Allow limiting quick actions to execute
Sometimes we don't want to trigger any quick actions that cause side
effects. For example when building a record to validate. This allows
listing the quick actions that need to be performed.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/quick_actions/extractor_spec.rb | 19 | ||||
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 9 |
2 files changed, 28 insertions, 0 deletions
diff --git a/spec/lib/gitlab/quick_actions/extractor_spec.rb b/spec/lib/gitlab/quick_actions/extractor_spec.rb index 0166f6c2ee0..873bb359d6e 100644 --- a/spec/lib/gitlab/quick_actions/extractor_spec.rb +++ b/spec/lib/gitlab/quick_actions/extractor_spec.rb @@ -272,5 +272,24 @@ describe Gitlab::QuickActions::Extractor do expect(commands).to be_empty expect(msg).to eq expected end + + it 'limits to passed commands when they are passed' do + msg = <<~MSG.strip + Hello, we should only extract the commands passed + /reopen + /labels hello world + /power + MSG + expected_msg = <<~EXPECTED.strip + Hello, we should only extract the commands passed + /power + EXPECTED + expected_commands = [['reopen'], ['labels', 'hello world']] + + msg, commands = extractor.extract_commands(msg, only: [:open, :labels]) + + expect(commands).to eq(expected_commands) + expect(msg).to eq expected_msg + end end end diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index e513ee7ae44..5a7cafcb60f 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1213,6 +1213,15 @@ describe QuickActions::InterpretService do end end end + + it 'limits to commands passed ' do + content = "/shrug\n/close" + + text, commands = service.execute(content, issue, only: [:shrug]) + + expect(commands).to be_empty + expect(text).to eq("#{described_class::SHRUG}\n/close") + end end describe '#explain' do |