Commit 974fe079 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch '41205-fix-filtering-issues' into 'master'

Filter issues without an Assignee via the API

Closes #41205

See merge request gitlab-org/gitlab-ce!22009
parents af0178aa 10534e31
...@@ -236,16 +236,16 @@ class IssuableFinder ...@@ -236,16 +236,16 @@ class IssuableFinder
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def assignee_id? def assignee_id?
params[:assignee_id].present? && params[:assignee_id] != NONE params[:assignee_id].present? && params[:assignee_id].to_s != NONE
end end
def assignee_username? def assignee_username?
params[:assignee_username].present? && params[:assignee_username] != NONE params[:assignee_username].present? && params[:assignee_username].to_s != NONE
end end
def no_assignee? def no_assignee?
# Assignee_id takes precedence over assignee_username # Assignee_id takes precedence over assignee_username
params[:assignee_id] == NONE || params[:assignee_username] == NONE params[:assignee_id].to_s == NONE || params[:assignee_username].to_s == NONE
end end
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
......
---
title: Filter issues without an Assignee via the API
merge_request: 22009
author: Eva Kadlecová
type: fixed
...@@ -56,6 +56,14 @@ describe IssuesFinder do ...@@ -56,6 +56,14 @@ describe IssuesFinder do
end end
end end
context 'filtering by no assignee' do
let(:params) { { assignee_id: 0 } }
it 'returns issues not assign to any assignee' do
expect(issues).to contain_exactly(issue4)
end
end
context 'filtering by group_id' do context 'filtering by group_id' do
let(:params) { { group_id: group.id } } let(:params) { { group_id: group.id } }
......
...@@ -168,6 +168,15 @@ describe API::Issues do ...@@ -168,6 +168,15 @@ describe API::Issues do
expect(first_issue['id']).to eq(issue2.id) expect(first_issue['id']).to eq(issue2.id)
end end
it 'returns issues with no assignee' do
issue2 = create(:issue, author: user2, project: project)
get api('/issues', user), assignee_id: 0, scope: 'all'
expect_paginated_array_response(size: 1)
expect(first_issue['id']).to eq(issue2.id)
end
it 'returns issues reacted by the authenticated user by the given emoji' do it 'returns issues reacted by the authenticated user by the given emoji' do
issue2 = create(:issue, project: project, author: user, assignees: [user]) issue2 = create(:issue, project: project, author: user, assignees: [user])
award_emoji = create(:award_emoji, awardable: issue2, user: user2, name: 'star') award_emoji = create(:award_emoji, awardable: issue2, user: user2, name: 'star')
......
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