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