Commit 28818864 authored by Peter Leitzen's avatar Peter Leitzen

Cannot mark a Commit as todo via `/todo`

parent 56ce4667
...@@ -301,6 +301,7 @@ module QuickActions ...@@ -301,6 +301,7 @@ module QuickActions
desc 'Add a todo' desc 'Add a todo'
explanation 'Adds a todo.' explanation 'Adds a todo.'
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
!TodoService.new.todo_exist?(issuable, current_user) !TodoService.new.todo_exist?(issuable, current_user)
end end
......
...@@ -637,16 +637,6 @@ describe QuickActions::InterpretService do ...@@ -637,16 +637,6 @@ describe QuickActions::InterpretService do
let(:issuable) { merge_request } let(:issuable) { merge_request }
end end
it_behaves_like 'todo command' do
let(:content) { '/todo' }
let(:issuable) { issue }
end
it_behaves_like 'todo command' do
let(:content) { '/todo' }
let(:issuable) { merge_request }
end
it_behaves_like 'done command' do it_behaves_like 'done command' do
let(:content) { '/done' } let(:content) { '/done' }
let(:issuable) { issue } let(:issuable) { issue }
...@@ -796,6 +786,28 @@ describe QuickActions::InterpretService do ...@@ -796,6 +786,28 @@ describe QuickActions::InterpretService do
let(:issuable) { issue } let(:issuable) { issue }
end end
context '/todo' do
let(:content) { '/todo' }
context 'if issuable is an Issue' do
it_behaves_like 'todo command' do
let(:issuable) { issue }
end
end
context 'if issuable is a MergeRequest' do
it_behaves_like 'todo command' do
let(:issuable) { merge_request }
end
end
context 'if issuable is a Commit' do
it_behaves_like 'empty command' do
let(:issuable) { commit }
end
end
end
context '/copy_metadata command' do context '/copy_metadata command' do
let(:todo_label) { create(:label, project: project, title: 'To Do') } let(:todo_label) { create(:label, project: project, title: 'To Do') }
let(:inreview_label) { create(:label, project: project, title: 'In Review') } let(:inreview_label) { create(:label, project: project, title: 'In Review') }
......
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