Commit 49b37da3 authored by Bob Van Landuyt's avatar Bob Van Landuyt

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

Support query for multiple states

See merge request gitlab-org/gitlab!18518
parents 36b83fbb 89c7abde
......@@ -188,11 +188,9 @@ class TodosFinder
end
def by_state(items)
if params[:state].to_s == 'done'
items.done
else
items.pending
end
return items.pending if params[:state].blank?
items.with_states(params[:state])
end
def by_type(items)
......
......@@ -140,6 +140,29 @@ describe TodosFinder do
end
end
end
context 'by state' do
let!(:todo1) { create(:todo, user: user, group: group, target: issue, state: :done) }
let!(:todo2) { create(:todo, user: user, group: group, target: issue, state: :pending) }
it 'returns the expected items when no state is provided' do
todos = finder.new(user, {}).execute
expect(todos).to match_array([todo2])
end
it 'returns the expected items when a state is provided' do
todos = finder.new(user, { state: :done }).execute
expect(todos).to match_array([todo1])
end
it 'returns the expected items when multiple states are provided' do
todos = finder.new(user, { state: [:pending, :done] }).execute
expect(todos).to match_array([todo1, todo2])
end
end
end
context 'external authorization' do
......
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