diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-16 17:49:53 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-16 17:49:53 -0500 |
commit | e07c27fee427195d8d89f6278d0fc12dfeec3588 (patch) | |
tree | c4676e5e953aecef8bf2bb715619027cd556c9cc /spec/services/todo_service_spec.rb | |
parent | 029b7d2e9266246feff2f165a10b16be1d7fe88e (diff) | |
parent | 415159c28da1aec00bb383d46aad67a9de75faae (diff) | |
download | gitlab-ce-e07c27fee427195d8d89f6278d0fc12dfeec3588.tar.gz |
Merge branch 'master' into 4273-slash-commands
# Conflicts:
# app/services/issues/create_service.rb
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r-- | spec/services/todo_service_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 4c41df0d4f5..0815da8826a 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -484,6 +484,42 @@ describe TodoService, services: true do expect(john_doe.todos_pending_count).to eq(1) end + describe '#mark_todos_as_done' do + let(:issue) { create(:issue, project: project, author: author, assignee: john_doe) } + + it 'marks a relation of todos as done' do + create(:todo, :mentioned, user: john_doe, target: issue, project: project) + + todos = TodosFinder.new(john_doe, {}).execute + expect { TodoService.new.mark_todos_as_done(todos, john_doe) } + .to change { john_doe.todos.done.count }.from(0).to(1) + end + + it 'marks an array of todos as done' do + todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) + + expect { TodoService.new.mark_todos_as_done([todo], john_doe) } + .to change { todo.reload.state }.from('pending').to('done') + end + + it 'returns the number of updated todos' do # Needed on API + todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) + + expect(TodoService.new.mark_todos_as_done([todo], john_doe)).to eq(1) + end + + it 'caches the number of todos of a user', :caching do + create(:todo, :mentioned, user: john_doe, target: issue, project: project) + todo = create(:todo, :mentioned, user: john_doe, target: issue, project: project) + TodoService.new.mark_todos_as_done([todo], john_doe) + + expect_any_instance_of(TodosFinder).not_to receive(:execute) + + expect(john_doe.todos_done_count).to eq(1) + expect(john_doe.todos_pending_count).to eq(1) + end + end + def should_create_todo(attributes = {}) attributes.reverse_merge!( project: project, |