Commit 18615b6f authored by Felipe Artur's avatar Felipe Artur

Validate last_test_report_state parameter

Validate last_test_report_state parameter used
to filter requirements.
parent 0d347294
...@@ -4,10 +4,13 @@ module RequirementsManagement ...@@ -4,10 +4,13 @@ module RequirementsManagement
class RequirementsFinder class RequirementsFinder
include Gitlab::Utils::StrongMemoize include Gitlab::Utils::StrongMemoize
ALLOWED_LAST_TEST_REPORT_STATE_VALUES = TestReport.states.keys.push("missing").freeze
# Params: # Params:
# project_id: integer # project_id: integer
# iids: integer[] # iids: integer[]
# state: string[] # state: string[]
# last_test_report_state: string
# sort: string # sort: string
# search: string # search: string
# author_username: string # author_username: string
...@@ -61,6 +64,7 @@ module RequirementsManagement ...@@ -61,6 +64,7 @@ module RequirementsManagement
def by_last_test_report_state(items) def by_last_test_report_state(items)
return items unless params[:last_test_report_state] return items unless params[:last_test_report_state]
return items unless ALLOWED_LAST_TEST_REPORT_STATE_VALUES.include?(params[:last_test_report_state])
if params[:last_test_report_state] == 'missing' if params[:last_test_report_state] == 'missing'
items.without_test_reports items.without_test_reports
......
...@@ -62,6 +62,18 @@ RSpec.describe RequirementsManagement::RequirementsFinder do ...@@ -62,6 +62,18 @@ RSpec.describe RequirementsManagement::RequirementsFinder do
is_expected.to match_array([requirement1, requirement3]) is_expected.to match_array([requirement1, requirement3])
end end
context 'when last_test_report_state is not valid' do
let(:params) { { project_id: project.id, last_test_report_state: 'not_valid' } }
it 'does not filter requirements' do
is_expected.to match_array([requirement1, requirement2, requirement3])
end
it 'does not raise error' do
expect { subject }.not_to raise_error
end
end
end end
context 'when user can not read requirements in the project' do context 'when user can not read requirements in the project' 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