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:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-07-19 17:16:28 +0300
commite4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch)
tree2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /spec/services/todo_service_spec.rb
parentffda4e7bcac36987f936b4ba515995a6698698f0 (diff)
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r--spec/services/todo_service_spec.rb51
1 files changed, 51 insertions, 0 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb
index 1ec6a3250fc..32e17df4d69 100644
--- a/spec/services/todo_service_spec.rb
+++ b/spec/services/todo_service_spec.rb
@@ -717,6 +717,57 @@ RSpec.describe TodoService, feature_category: :team_planning do
end
end
+ describe 'Work Items' do
+ let_it_be(:work_item) { create(:work_item, :task, project: project, author: author) }
+
+ describe '#mark_todo' do
+ it 'creates a todo from a work item' do
+ service.mark_todo(work_item, author)
+
+ should_create_todo(user: author, target: work_item, action: Todo::MARKED)
+ end
+ end
+
+ describe '#todo_exists?' do
+ it 'returns false when no todo exist for the given work_item' do
+ expect(service.todo_exist?(work_item, author)).to be_falsy
+ end
+
+ it 'returns true when a todo exist for the given work_item' do
+ service.mark_todo(work_item, author)
+
+ expect(service.todo_exist?(work_item, author)).to be_truthy
+ end
+ end
+
+ describe '#resolve_todos_for_target' do
+ it 'marks related pending todos to the target for the user as done' do
+ first_todo = create(:todo, :assigned, user: john_doe, project: project, target: work_item, author: author)
+ second_todo = create(:todo, :assigned, user: john_doe, project: project, target: work_item, author: author)
+
+ service.resolve_todos_for_target(work_item, john_doe)
+
+ expect(first_todo.reload).to be_done
+ expect(second_todo.reload).to be_done
+ end
+
+ describe 'cached counts' do
+ it 'updates when todos change' do
+ create(:todo, :assigned, user: john_doe, project: project, target: work_item, author: author)
+
+ expect(john_doe.todos_done_count).to eq(0)
+ expect(john_doe.todos_pending_count).to eq(1)
+ expect(john_doe).to receive(:update_todos_count_cache).and_call_original
+
+ service.resolve_todos_for_target(work_item, john_doe)
+
+ expect(john_doe.todos_done_count).to eq(1)
+ expect(john_doe.todos_pending_count).to eq(0)
+ end
+ end
+ end
+ end
+
describe '#reassigned_assignable' do
let(:described_method) { :reassigned_assignable }