Commit bf7846be authored by Robert Schilling's avatar Robert Schilling

Only use boolean parameters internally

Use internally only boolean params.
parent 56a54c62
......@@ -91,7 +91,7 @@ module IssuableCollections
options = {
scope: params[:scope],
state: params[:state],
confidential: params[:confidential],
confidential: Gitlab::Utils.to_boolean(params[:confidential]),
sort: set_sort_order
}
......
......@@ -69,14 +69,16 @@ class IssuesFinder < IssuableFinder
end
def filter_items(items)
issues = by_due_date(super)
by_confidential(issues)
issues = super
issues = by_due_date(issues)
issues = by_confidential(issues)
issues
end
def by_confidential(items)
return items unless params[:confidential].present?
return items if params[:confidential].nil?
params[:confidential] == 'yes' ? items.confidential_only : items.public_only
params[:confidential] ? items.confidential_only : items.public_only
end
def by_due_date(items)
......
......@@ -15,14 +15,6 @@ module API
params :issue_params_ee do
end
def convert_confidential_param(args)
confidential = args.delete(:confidential)
return args if confidential.nil?
args[:confidential] = confidential ? 'yes' : 'no'
args
end
end
helpers do
......@@ -34,7 +26,6 @@ module API
args[:milestone_title] = args.delete(:milestone)
args[:label_name] = args.delete(:labels)
args[:scope] = args[:scope].underscore if args[:scope]
args = convert_confidential_param(args)
issues = IssuesFinder.new(current_user, args).execute
.preload(:assignees, :labels, :notes, :timelogs, :project, :author, :closed_by)
......
......@@ -112,8 +112,8 @@ describe IssuableCollections do
assignee_username: 'user1',
author_id: '2',
author_username: 'user2',
authorized_only: 'true',
confidential: 'yes',
authorized_only: 'yes',
confidential: true,
due_date: '2017-01-01',
group_id: '3',
iids: '4',
......@@ -141,7 +141,7 @@ describe IssuableCollections do
'assignee_username' => 'user1',
'author_id' => '2',
'author_username' => 'user2',
'confidential' => 'yes',
'confidential' => true,
'label_name' => 'foo',
'milestone_title' => 'bar',
'my_reaction_emoji' => 'thumbsup',
......
......@@ -470,7 +470,7 @@ describe IssuesFinder do
end
context 'user filters confidential issues' do
let(:params) { { confidential: 'yes' } }
let(:params) { { confidential: true } }
it 'returns only confdential issues' do
expect(issues).to contain_exactly(confidential_issue)
......@@ -478,7 +478,7 @@ describe IssuesFinder do
end
context 'user filters only public issues' do
let(:params) { { confidential: 'no' } }
let(:params) { { confidential: false } }
it 'returns only confdential issues' do
expect(issues).to contain_exactly(issue1, issue2, issue3, issue4)
......
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