diff options
author | Felipe Artur <fcardozo@gitlab.com> | 2019-03-04 09:21:47 +0000 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2019-03-04 09:21:47 +0000 |
commit | 78dc1b58a64be03e6d3622aab5605e1d5f6a6643 (patch) | |
tree | d0dd8c328bb0c7ce2311c79f525f7f23db9e0ff0 /spec/services | |
parent | 4b0036b87ee30ce0a3687dd052514b571f4d520f (diff) | |
download | gitlab-ce-78dc1b58a64be03e6d3622aab5605e1d5f6a6643.tar.gz |
Show commands applied message when promoting issues
Fix 'commands applied' messages not being shown when issue is promoted to epic
using slash commands.
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 13 | ||||
-rw-r--r-- | spec/services/notes/quick_actions_service_spec.rb | 24 | ||||
-rw-r--r-- | spec/services/quick_actions/interpret_service_spec.rb | 10 |
3 files changed, 35 insertions, 12 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 1645b67c329..8d8e81173ff 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -220,6 +220,19 @@ describe Notes::CreateService do expect(note.note).to eq "HELLO\nWORLD" end end + + context 'when note only have commands' do + it 'adds commands applied message to note errors' do + note_text = %(/close) + service = double(:service) + allow(Issues::UpdateService).to receive(:new).and_return(service) + expect(service).to receive(:execute) + + note = described_class.new(project, user, opts.merge(note: note_text)).execute + + expect(note.errors[:commands_only]).to be_present + end + end end context 'as a user who cannot update the target' do diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index 14d62763a5b..7d2b6d5b8a7 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -28,8 +28,8 @@ describe Notes::QuickActionsService do end it 'closes noteable, sets labels, assigns, and sets milestone to noteable, and leave no note' do - content, command_params = service.extract_commands(note) - service.execute(command_params, note) + content, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(content).to eq '' expect(note.noteable).to be_closed @@ -47,8 +47,8 @@ describe Notes::QuickActionsService do let(:note_text) { '/reopen' } it 'opens the noteable, and leave no note' do - content, command_params = service.extract_commands(note) - service.execute(command_params, note) + content, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(content).to eq '' expect(note.noteable).to be_open @@ -59,8 +59,8 @@ describe Notes::QuickActionsService do let(:note_text) { '/spend 1h' } it 'updates the spent time on the noteable' do - content, command_params = service.extract_commands(note) - service.execute(command_params, note) + content, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(content).to eq '' expect(note.noteable.time_spent).to eq(3600) @@ -75,8 +75,8 @@ describe Notes::QuickActionsService do end it 'closes noteable, sets labels, assigns, and sets milestone to noteable' do - content, command_params = service.extract_commands(note) - service.execute(command_params, note) + content, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(content).to eq "HELLO\nWORLD" expect(note.noteable).to be_closed @@ -94,8 +94,8 @@ describe Notes::QuickActionsService do let(:note_text) { "HELLO\n/reopen\nWORLD" } it 'opens the noteable' do - content, command_params = service.extract_commands(note) - service.execute(command_params, note) + content, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(content).to eq "HELLO\nWORLD" expect(note.noteable).to be_open @@ -190,8 +190,8 @@ describe Notes::QuickActionsService do end it 'adds only one assignee from the list' do - _, command_params = service.extract_commands(note) - service.execute(command_params, note) + _, update_params = service.execute(note) + service.apply_updates(update_params, note) expect(note.noteable.assignees.count).to eq(1) end diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb index 938764f40b0..ea33d156c8a 100644 --- a/spec/services/quick_actions/interpret_service_spec.rb +++ b/spec/services/quick_actions/interpret_service_spec.rb @@ -1526,5 +1526,15 @@ describe QuickActions::InterpretService do end end end + + context "#commands_executed_count" do + it 'counts commands executed' do + content = "/close and \n/assign me and \n/title new title" + + service.execute(content, issue) + + expect(service.commands_executed_count).to eq(3) + end + end end end |