Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r--spec/services/todo_service_spec.rb80
1 files changed, 76 insertions, 4 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 0888c27aab2..0b4cf9e53db 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -5,6 +5,7 @@ require 'spec_helper'
RSpec.describe TodoService, feature_category: :team_planning do
include AfterNextHelpers
+ let_it_be(:group) { create(:group) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:author) { create(:user) }
let_it_be(:assignee) { create(:user) }
@@ -31,11 +32,18 @@ RSpec.describe TodoService, feature_category: :team_planning do
end
shared_examples 'reassigned target' do
+ let(:additional_todo_attributes) { {} }
+
it 'creates a pending todo for new assignee' do
target_unassigned.assignees = [john_doe]
service.send(described_method, target_unassigned, author)
- should_create_todo(user: john_doe, target: target_unassigned, action: Todo::ASSIGNED)
+ should_create_todo(
+ user: john_doe,
+ target: target_unassigned,
+ action: Todo::ASSIGNED,
+ **additional_todo_attributes
+ )
end
it 'does not create a todo if unassigned' do
@@ -48,7 +56,13 @@ RSpec.describe TodoService, feature_category: :team_planning do
target_assigned.assignees = [john_doe]
service.send(described_method, target_assigned, john_doe)
- should_create_todo(user: john_doe, target: target_assigned, author: john_doe, action: Todo::ASSIGNED)
+ should_create_todo(
+ user: john_doe,
+ target: target_assigned,
+ author: john_doe,
+ action: Todo::ASSIGNED,
+ **additional_todo_attributes
+ )
end
it 'does not create a todo for guests' do
@@ -657,11 +671,27 @@ RSpec.describe TodoService, feature_category: :team_planning do
end
describe '#mark_todo' do
- it 'creates a todo from a issue' do
+ it 'creates a todo from an issue' do
service.mark_todo(unassigned_issue, author)
should_create_todo(user: author, target: unassigned_issue, action: Todo::MARKED)
end
+
+ context 'when issue belongs to a group' do
+ it 'creates a todo from an issue' do
+ group_issue = create(:issue, :group_level, namespace: group)
+ service.mark_todo(group_issue, group_issue.author)
+
+ should_create_todo(
+ user: group_issue.author,
+ author: group_issue.author,
+ target: group_issue,
+ action: Todo::MARKED,
+ project: nil,
+ group: group
+ )
+ end
+ end
end
describe '#todo_exists?' do
@@ -726,6 +756,22 @@ RSpec.describe TodoService, feature_category: :team_planning do
should_create_todo(user: author, target: work_item, action: Todo::MARKED)
end
+
+ context 'when work item belongs to a group' do
+ it 'creates a todo from a work item' do
+ group_work_item = create(:work_item, :group_level, namespace: group)
+ service.mark_todo(group_work_item, group_work_item.author)
+
+ should_create_todo(
+ user: group_work_item.author,
+ author: group_work_item.author,
+ target: group_work_item,
+ action: Todo::MARKED,
+ project: nil,
+ group: group
+ )
+ end
+ end
end
describe '#todo_exists?' do
@@ -779,7 +825,7 @@ RSpec.describe TodoService, feature_category: :team_planning do
end
end
- context 'assignable is an issue' do
+ context 'assignable is a project level issue' do
it_behaves_like 'reassigned target' do
let(:target_assigned) { create(:issue, project: project, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
let(:addressed_target_assigned) { create(:issue, project: project, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
@@ -787,6 +833,32 @@ RSpec.describe TodoService, feature_category: :team_planning do
end
end
+ context 'assignable is a project level work_item' do
+ it_behaves_like 'reassigned target' do
+ let(:target_assigned) { create(:work_item, project: project, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
+ let(:addressed_target_assigned) { create(:work_item, project: project, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
+ let(:target_unassigned) { create(:work_item, project: project, author: author, assignees: []) }
+ end
+ end
+
+ context 'assignable is a group level issue' do
+ it_behaves_like 'reassigned target' do
+ let(:additional_todo_attributes) { { project: nil, group: group } }
+ let(:target_assigned) { create(:issue, :group_level, namespace: group, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
+ let(:addressed_target_assigned) { create(:issue, :group_level, namespace: group, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
+ let(:target_unassigned) { create(:issue, :group_level, namespace: group, author: author, assignees: []) }
+ end
+ end
+
+ context 'assignable is a group level work item' do
+ it_behaves_like 'reassigned target' do
+ let(:additional_todo_attributes) { { project: nil, group: group } }
+ let(:target_assigned) { create(:work_item, :group_level, namespace: group, author: author, assignees: [john_doe], description: "- [ ] Task 1\n- [ ] Task 2 #{mentions}") }
+ let(:addressed_target_assigned) { create(:work_item, :group_level, namespace: group, author: author, assignees: [john_doe], description: "#{directly_addressed}\n- [ ] Task 1\n- [ ] Task 2") }
+ let(:target_unassigned) { create(:work_item, :group_level, namespace: group, author: author, assignees: []) }
+ end
+ end
+
context 'assignable is an alert' do
it_behaves_like 'reassigned target' do
let(:target_assigned) { create(:alert_management_alert, project: project, assignees: [john_doe]) }