diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-11 12:15:23 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-11 12:15:23 +0300 |
commit | 5f6fe673fa797f46ee747df4553a9c216224bb85 (patch) | |
tree | c0a977fc562f13ff43ebdf3957add21f079b1b99 /spec/services | |
parent | 465493946771106953b9d2e70a27b69463af4299 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 85 |
1 files changed, 44 insertions, 41 deletions
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 3cca4127610..dc93fd96aee 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -554,14 +554,14 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning end end - shared_examples 'award command' do - it 'toggle award 100 emoji if content contains /award :100:' do + shared_examples 'react command' do |command| + it "toggle award 100 emoji if content contains #{command} :100:" do _, updates, _ = service.execute(content, issuable) expect(updates).to eq(emoji_award: "100") end - it 'returns the award message' do + it 'returns the reaction message' do _, _, message = service.execute(content, issuable) expect(message).to eq('Toggled :100: emoji award.') @@ -1861,56 +1861,59 @@ RSpec.describe QuickActions::InterpretService, feature_category: :team_planning end end - context '/award command' do - it_behaves_like 'award command' do - let(:content) { '/award :100:' } - let(:issuable) { issue } - end - - it_behaves_like 'award command' do - let(:content) { '/award :100:' } - let(:issuable) { merge_request } - end - - it_behaves_like 'award command' do - let(:content) { '/award :100:' } - let(:issuable) { work_item } - end - - context 'ignores command with no argument' do - it_behaves_like 'failed command' do - let(:content) { '/award' } + %w[/react /award].each do |command| + context "#{command} command" do + it_behaves_like 'react command', command do + let(:content) { "#{command} :100:" } let(:issuable) { issue } end - it_behaves_like 'failed command' do - let(:content) { '/award' } - let(:issuable) { work_item } + it_behaves_like 'react command', command do + let(:content) { "#{command} :100:" } + let(:issuable) { merge_request } end - end - context 'ignores non-existing / invalid emojis' do - it_behaves_like 'failed command' do - let(:content) { '/award noop' } - let(:issuable) { issue } + it_behaves_like 'react command', command do + let(:content) { "#{command} :100:" } + let(:issuable) { work_item } end - it_behaves_like 'failed command' do - let(:content) { '/award :lorem_ipsum:' } - let(:issuable) { issue } + context 'ignores command with no argument' do + it_behaves_like 'failed command' do + let(:content) { command } + let(:issuable) { issue } + end + + it_behaves_like 'failed command' do + let(:content) { command } + let(:issuable) { work_item } + end end - it_behaves_like 'failed command' do - let(:content) { '/award :lorem_ipsum:' } - let(:issuable) { work_item } + context 'ignores non-existing / invalid emojis' do + it_behaves_like 'failed command' do + let(:content) { "#{command} noop" } + let(:issuable) { issue } + end + + it_behaves_like 'failed command' do + let(:content) { "#{command} :lorem_ipsum:" } + let(:issuable) { issue } + end + + it_behaves_like 'failed command' do + let(:content) { "#{command} :lorem_ipsum:" } + let(:issuable) { work_item } + end end - end - context 'if issuable is a Commit' do - let(:content) { '/award :100:' } - let(:issuable) { commit } + context 'if issuable is a Commit' do + let(:content) { "#{command} :100:" } + let(:issuable) { commit } - it_behaves_like 'failed command', 'Could not apply award command.' + # TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/434446 + it_behaves_like 'failed command', "Could not apply award command." + end end end |