diff options
author | Sean McGivern <sean@gitlab.com> | 2017-12-08 15:17:22 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-12-18 15:23:00 +0300 |
commit | ef454f68e837e4e7360fe1518686dd56adbbb0a9 (patch) | |
tree | 72e67bbf1a2222d8a1007298478350b5cc9c02bd /spec/services/issuable | |
parent | 9429e8ac60a10436a0469d7d206d3f74a2c966c7 (diff) |
Reset todo counters when the target is deleted
When the target is deleted, todos are destroyed, but we did not reset the todo
cache for users with todos on the deleted target. This would only update after
the next time the todo cache was updated for that user.
Diffstat (limited to 'spec/services/issuable')
-rw-r--r-- | spec/services/issuable/destroy_service_spec.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/spec/services/issuable/destroy_service_spec.rb b/spec/services/issuable/destroy_service_spec.rb index d74d98c6079..0a3647a814f 100644 --- a/spec/services/issuable/destroy_service_spec.rb +++ b/spec/services/issuable/destroy_service_spec.rb @@ -2,7 +2,7 @@ require 'spec_helper' describe Issuable::DestroyService do let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :public) } subject(:service) { described_class.new(project, user) } @@ -19,6 +19,13 @@ describe Issuable::DestroyService do service.execute(issue) end + + it 'updates the todo caches for users with todos on the issue' do + create(:todo, target: issue, user: user, author: user, project: project) + + expect { service.execute(issue) } + .to change { user.todos_pending_count }.from(1).to(0) + end end context 'when issuable is a merge request' do @@ -33,6 +40,13 @@ describe Issuable::DestroyService do service.execute(merge_request) end + + it 'updates the todo caches for users with todos on the merge request' do + create(:todo, target: merge_request, user: user, author: user, project: project) + + expect { service.execute(merge_request) } + .to change { user.todos_pending_count }.from(1).to(0) + end end end end |