Commit 09e1faa8 authored by Ruben Davila's avatar Ruben Davila

Add specs for new Slash commands: /estimate & /spend

parent 0140e7aa
......@@ -84,6 +84,18 @@ describe Notes::SlashCommandsService, services: true do
expect(note.noteable).to be_open
end
end
describe '/spend' 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)
expect(content).to eq ''
expect(note.noteable.time_spent).to eq(3600)
end
end
end
describe 'note with command & text' do
......
......@@ -210,6 +210,22 @@ describe SlashCommands::InterpretService, services: true do
end
end
shared_examples 'estimate command' do
it 'populates time_estimate: "3600" if content contains /estimate 1h' do
_, updates = service.execute(content, issuable)
expect(updates).to eq(time_estimate: 3600)
end
end
shared_examples 'spend command' do
it 'populates time_spent: "3600" if content contains /spend 1h' do
_, updates = service.execute(content, issuable)
expect(updates).to eq(time_spent: 3600)
end
end
shared_examples 'empty command' do
it 'populates {} if content contains an unsupported command' do
_, updates = service.execute(content, issuable)
......@@ -500,6 +516,16 @@ describe SlashCommands::InterpretService, services: true do
let(:content) { '/remove_due_date' }
let(:issuable) { issue }
end
it_behaves_like 'estimate command' do
let(:content) { '/estimate 1h' }
let(:issuable) { issue }
end
it_behaves_like 'spend command' do
let(:content) { '/spend 1h' }
let(:issuable) { issue }
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment