diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-08-16 22:10:37 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-08-18 17:46:24 +0200 |
commit | 548da42be51821951180eacf462d942c11c0c01b (patch) | |
tree | 56d3335fe86ae4c4a2dfc26951d241c8d762d34e /spec/services/todo_service_spec.rb | |
parent | 30654fc9c1afc222ebae5c5367657bd8f6e615b2 (diff) | |
download | gitlab-ce-548da42be51821951180eacf462d942c11c0c01b.tar.gz |
Implement TodoService#mark_todos_as_done_by_id
Follow-up on 52b0c26
Diffstat (limited to 'spec/services/todo_service_spec.rb')
-rw-r--r-- | spec/services/todo_service_spec.rb | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/spec/services/todo_service_spec.rb b/spec/services/todo_service_spec.rb index 6c3cbeae13c..9db05cce732 100644 --- a/spec/services/todo_service_spec.rb +++ b/spec/services/todo_service_spec.rb @@ -194,12 +194,12 @@ describe TodoService, services: true do end end - describe '#mark_todos_as_done' do - it 'marks related todos for the user as done' do - first_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) - second_todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) + shared_examples 'marking todos as done' do |meth| + let!(:first_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) } + let!(:second_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) } - service.mark_todos_as_done([first_todo, second_todo], john_doe) + it 'marks related todos for the user as done' do + service.send(meth, collection, john_doe) expect(first_todo.reload).to be_done expect(second_todo.reload).to be_done @@ -207,20 +207,30 @@ describe TodoService, services: true do describe 'cached counts' do it 'updates when todos change' do - todo = create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) - expect(john_doe.todos_done_count).to eq(0) - expect(john_doe.todos_pending_count).to eq(1) + expect(john_doe.todos_pending_count).to eq(2) expect(john_doe).to receive(:update_todos_count_cache).and_call_original - service.mark_todos_as_done([todo], john_doe) + service.send(meth, collection, john_doe) - expect(john_doe.todos_done_count).to eq(1) + expect(john_doe.todos_done_count).to eq(2) expect(john_doe.todos_pending_count).to eq(0) end end end + describe '#mark_todos_as_done' do + it_behaves_like 'marking todos as done', :mark_todos_as_done do + let(:collection) { [first_todo, second_todo] } + end + end + + describe '#mark_todos_as_done_by_id' do + it_behaves_like 'marking todos as done', :mark_todos_as_done_by_id do + let(:collection) { [first_todo, second_todo].map(&:id) } + end + end + describe '#new_note' do let!(:first_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) } let!(:second_todo) { create(:todo, :assigned, user: john_doe, project: project, target: issue, author: author) } |