Commit e4569d25 authored by Jarka Kadlecová's avatar Jarka Kadlecová

Create todos only for newly mentioned users on epics

parent d90635ef
......@@ -3,11 +3,14 @@ module Epics
def execute(epic)
update(epic)
# TODO: old_mentioned_users
# TODO: move to handle_changes method
todo_service.update_epic(epic, current_user, [])
epic
end
def handle_changes(epic, options)
old_associations = options.fetch(:old_associations, {})
old_mentioned_users = old_associations.fetch(:mentioned_users, [])
todo_service.update_epic(epic, current_user, old_mentioned_users)
end
end
end
......@@ -6,6 +6,9 @@ describe Epics::UpdateService do
let(:epic) { create(:epic, group: group) }
describe '#execute' do
before do
stub_licensed_features(epics: true)
end
def update_epic(opts)
described_class.new(group, user, opts).execute(epic)
end
......@@ -56,5 +59,21 @@ describe Epics::UpdateService do
expect(note.noteable).to eq(epic)
end
end
context 'todos' do
let(:mentioned1) { create(:user) }
let(:mentioned2) { create(:user) }
before do
group.update(visibility: Gitlab::VisibilityLevel::PUBLIC)
epic.update(description: "FYI: #{mentioned1.to_reference}")
end
it 'creates todos for only newly mentioned users' do
expect {
update_epic(description: "FYI: #{mentioned1.to_reference} #{mentioned2.to_reference}")
}.to change { Todo.count }.by(1)
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