diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-06-16 21:25:58 +0300 |
commit | a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch) | |
tree | fb69158581673816a8cd895f9d352dcb3c678b1e /spec/finders/pending_todos_finder_spec.rb | |
parent | d16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff) |
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'spec/finders/pending_todos_finder_spec.rb')
-rw-r--r-- | spec/finders/pending_todos_finder_spec.rb | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/spec/finders/pending_todos_finder_spec.rb b/spec/finders/pending_todos_finder_spec.rb index b17915f0d59..f317d8b1633 100644 --- a/spec/finders/pending_todos_finder_spec.rb +++ b/spec/finders/pending_todos_finder_spec.rb @@ -3,8 +3,11 @@ require 'spec_helper' RSpec.describe PendingTodosFinder do - let(:user) { create(:user) } - let(:user2) { create(:user) } + let_it_be(:user) { create(:user) } + let_it_be(:user2) { create(:user) } + let_it_be(:issue) { create(:issue) } + let_it_be(:note) { create(:note) } + let(:users) { [user, user2] } describe '#execute' do @@ -30,20 +33,16 @@ RSpec.describe PendingTodosFinder do end it 'supports retrieving of todos for a specific todo target' do - issue = create(:issue) - note = create(:note) todo = create(:todo, :pending, user: user, target: issue) create(:todo, :pending, user: user, target: note) - todos = described_class.new(users, target_id: issue.id).execute + todos = described_class.new(users, target_id: issue.id, target_type: 'Issue').execute expect(todos).to eq([todo]) end it 'supports retrieving of todos for a specific target type' do - issue = create(:issue) - note = create(:note) todo = create(:todo, :pending, user: user, target: issue) create(:todo, :pending, user: user, target: note) @@ -61,5 +60,20 @@ RSpec.describe PendingTodosFinder do expect(todos).to eq([todo]) end + + it 'supports retrieving of todos for specific discussion' do + first_discussion_note = create(:discussion_note_on_issue, noteable: issue, project: issue.project) + note_2 = create(:note, discussion_id: first_discussion_note.discussion_id) + note_3 = create(:note, discussion_id: first_discussion_note.discussion_id) + todo1 = create(:todo, :pending, target: issue, note: note_2, user: note_2.author) + todo2 = create(:todo, :pending, target: issue, note: note_3, user: note_3.author) + create(:todo, :pending, note: note, user: user) + discussion = Discussion.lazy_find(first_discussion_note.discussion_id) + users = [note_2.author, note_3.author, user] + + todos = described_class.new(users, discussion: discussion).execute + + expect(todos).to contain_exactly(todo1, todo2) + end end end |