Commit 3271ff96 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '31914-support-multiple-query-on-todos-finder-type-pd' into 'master'

Add spec for filtering by multiple types

See merge request gitlab-org/gitlab!18489
parents 15a14a9e 993fe2ab
...@@ -36,12 +36,20 @@ describe TodosFinder do ...@@ -36,12 +36,20 @@ describe TodosFinder do
expect(todos).to match_array([todo1, todo2]) expect(todos).to match_array([todo1, todo2])
end end
context 'when filtering by type' do
it 'returns correct todos when filtered by a type' do it 'returns correct todos when filtered by a type' do
todos = finder.new(user, { type: 'Issue' }).execute todos = finder.new(user, { type: 'Issue' }).execute
expect(todos).to match_array([todo1]) expect(todos).to match_array([todo1])
end end
it 'returns the correct todos when filtering for multiple types' do
todos = finder.new(user, { type: %w[Issue MergeRequest] }).execute
expect(todos).to match_array([todo1, todo2])
end
end
context 'when filtering for actions' do context 'when filtering for actions' do
let!(:todo1) { create(:todo, user: user, project: project, target: issue, action: Todo::ASSIGNED) } let!(:todo1) { create(:todo, user: user, project: project, target: issue, action: Todo::ASSIGNED) }
let!(:todo2) { create(:todo, user: user, group: group, target: merge_request, action: Todo::DIRECTLY_ADDRESSED) } let!(:todo2) { create(:todo, user: user, group: group, target: merge_request, action: Todo::DIRECTLY_ADDRESSED) }
...@@ -53,14 +61,12 @@ describe TodosFinder do ...@@ -53,14 +61,12 @@ describe TodosFinder do
expect(todos).to match_array([todo2]) expect(todos).to match_array([todo2])
end end
context 'multiple actions' do it 'returns the expected todos when filtering for multiple action ids' do
it 'returns the expected todos' do
todos = finder.new(user, { action_id: [Todo::DIRECTLY_ADDRESSED, Todo::ASSIGNED] }).execute todos = finder.new(user, { action_id: [Todo::DIRECTLY_ADDRESSED, Todo::ASSIGNED] }).execute
expect(todos).to match_array([todo2, todo1]) expect(todos).to match_array([todo2, todo1])
end end
end end
end
context 'by action names' do context 'by action names' do
it 'returns the expected todos' do it 'returns the expected todos' do
...@@ -69,15 +75,13 @@ describe TodosFinder do ...@@ -69,15 +75,13 @@ describe TodosFinder do
expect(todos).to match_array([todo2]) expect(todos).to match_array([todo2])
end end
context 'multiple actions' do it 'returns the expected todos when filtering for multiple action names' do
it 'returns the expected todos' do
todos = finder.new(user, { action: [:directly_addressed, :assigned] }).execute todos = finder.new(user, { action: [:directly_addressed, :assigned] }).execute
expect(todos).to match_array([todo2, todo1]) expect(todos).to match_array([todo2, todo1])
end end
end end
end end
end
context 'when filtering by author' do context 'when filtering by author' do
let(:author1) { create(:user) } let(:author1) { create(:user) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment