Commit ec44773b authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '227854-add-backend-support-for-open-closed-all-states' into 'master'

Add backend support for Jira issue list open/closed/all states

Closes #227854 and #227835

See merge request gitlab-org/gitlab!36626
parents 58a7f989 a0c0d395
......@@ -13,6 +13,7 @@ module Jira
@search = params[:search]
@labels = params[:labels]
@status = params[:status]
@state = params[:state]
@reporter = params[:author_username]
@assignee = params[:assignee_username]
@sort = params[:sort] || DEFAULT_SORT
......@@ -28,7 +29,7 @@ module Jira
private
attr_reader :jira_project_key, :sort, :sort_direction, :search, :labels, :status, :reporter, :assignee
attr_reader :jira_project_key, :sort, :sort_direction, :search, :labels, :status, :reporter, :assignee, :state
def jql_filters
[
......@@ -37,6 +38,7 @@ module Jira
by_status,
by_reporter,
by_assignee,
by_open_and_closed,
by_summary_and_description
].compact.join(' AND ')
end
......@@ -80,6 +82,17 @@ module Jira
%Q[assignee = "#{escape_quotes(assignee)}"]
end
def by_open_and_closed
return if state.blank?
case state
when 'opened'
%q[statusCategory != Done]
when 'closed'
%q[statusCategory = Done]
end
end
def escape_quotes(param)
param.gsub('\\', '\\\\\\').gsub('"', '\\"')
end
......
......@@ -85,5 +85,29 @@ RSpec.describe Jira::JqlBuilderService do
expect(subject).to eq('project = PROJECT_KEY order by updated ASC')
end
end
context 'with opened state param' do
let(:params) { { state: 'opened' } }
it 'builds jql' do
expect(subject).to eq('project = PROJECT_KEY AND statusCategory != Done order by created DESC')
end
end
context 'with closed state param' do
let(:params) { { state: 'closed' } }
it 'builds jql' do
expect(subject).to eq('project = PROJECT_KEY AND statusCategory = Done order by created DESC')
end
end
context 'with any other state param' do
let(:params) { { state: 'all' } }
it 'builds jql' do
expect(subject).to eq('project = PROJECT_KEY order by created DESC')
end
end
end
end
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