Explicit mention of the assignee make a task

Since potentially the previous assign-task has already been handled.
parent 424cb9cc
...@@ -150,7 +150,6 @@ class TaskService ...@@ -150,7 +150,6 @@ class TaskService
end end
mentioned_users.delete(author) mentioned_users.delete(author)
mentioned_users.delete(target.assignee) if target.respond_to?(:assignee)
mentioned_users.uniq mentioned_users.uniq
end end
...@@ -177,6 +176,7 @@ class TaskService ...@@ -177,6 +176,7 @@ class TaskService
end end
mentioned_users = build_mentioned_users(project, target, author) mentioned_users = build_mentioned_users(project, target, author)
mentioned_users.delete(issuable.assignee)
mentioned_users.each do |mentioned_user| mentioned_users.each do |mentioned_user|
create_task(project, target, author, mentioned_user, Task::MENTIONED) create_task(project, target, author, mentioned_user, Task::MENTIONED)
...@@ -185,16 +185,15 @@ class TaskService ...@@ -185,16 +185,15 @@ class TaskService
def update_issuable(issuable, current_user) def update_issuable(issuable, current_user)
project = issuable.project project = issuable.project
target = issuable
author = current_user author = current_user
mark_pending_tasks_as_done(target, author) mark_pending_tasks_as_done(issuable, author)
mentioned_users = build_mentioned_users(project, target, author) mentioned_users = build_mentioned_users(project, issuable, author)
mentioned_users.each do |mentioned_user| mentioned_users.each do |mentioned_user|
unless pending_tasks(mentioned_user, project, target, action: Task::MENTIONED).exists? unless pending_tasks(mentioned_user, project, issuable, action: Task::MENTIONED).exists?
create_task(project, target, author, mentioned_user, Task::MENTIONED) create_task(project, issuable, author, mentioned_user, Task::MENTIONED)
end end
end end
end end
......
...@@ -56,15 +56,15 @@ describe TaskService, services: true do ...@@ -56,15 +56,15 @@ describe TaskService, services: true do
service.update_issue(issue, author) service.update_issue(issue, author)
should_create_task(user: michael, target: issue, action: Task::MENTIONED) should_create_task(user: michael, target: issue, action: Task::MENTIONED)
should_create_task(user: john_doe, target: issue, action: Task::MENTIONED)
should_not_create_task(user: author, target: issue, action: Task::MENTIONED) should_not_create_task(user: author, target: issue, action: Task::MENTIONED)
should_not_create_task(user: john_doe, target: issue, action: Task::MENTIONED)
should_not_create_task(user: stranger, target: issue, action: Task::MENTIONED) should_not_create_task(user: stranger, target: issue, action: Task::MENTIONED)
end end
it 'does not create a task if user was already mentioned' do it 'does not create a task if user was already mentioned' do
create(:task, :mentioned, user: michael, project: project, target: issue, author: author) create(:task, :mentioned, user: michael, project: project, target: issue, author: author)
should_not_create_any_task { service.update_issue(issue, author) } expect { service.update_issue(issue, author) }.not_to change(michael.tasks, :count)
end end
end end
...@@ -184,15 +184,15 @@ describe TaskService, services: true do ...@@ -184,15 +184,15 @@ describe TaskService, services: true do
service.update_merge_request(mr_assigned, author) service.update_merge_request(mr_assigned, author)
should_create_task(user: michael, target: mr_assigned, action: Task::MENTIONED) should_create_task(user: michael, target: mr_assigned, action: Task::MENTIONED)
should_create_task(user: john_doe, target: mr_assigned, action: Task::MENTIONED)
should_not_create_task(user: author, target: mr_assigned, action: Task::MENTIONED) should_not_create_task(user: author, target: mr_assigned, action: Task::MENTIONED)
should_not_create_task(user: john_doe, target: mr_assigned, action: Task::MENTIONED)
should_not_create_task(user: stranger, target: mr_assigned, action: Task::MENTIONED) should_not_create_task(user: stranger, target: mr_assigned, action: Task::MENTIONED)
end end
it 'does not create a task if user was already mentioned' do it 'does not create a task if user was already mentioned' do
create(:task, :mentioned, user: michael, project: project, target: mr_assigned, author: author) create(:task, :mentioned, user: michael, project: project, target: mr_assigned, author: author)
should_not_create_any_task { service.update_merge_request(mr_assigned, author) } expect { service.update_merge_request(mr_assigned, author) }.not_to change(michael.tasks, :count)
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