Commit 7e967fb9 authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '196729_cast_project_ids_to_integer_in_api_response' into 'master'

Do not cast project IDs to string in API response

Closes #196729

See merge request gitlab-org/gitlab!30047
parents 21343680 a8a14452
......@@ -31,9 +31,9 @@ module Dashboard
end
def find_invalid_ids(projects_to_add, project_ids)
found_ids = projects_to_add.map(&:id).map(&:to_s)
found_ids = projects_to_add.map(&:id)
project_ids.map(&:to_s) - found_ids
project_ids.map(&:to_i) - found_ids
end
def add_projects(projects)
......
---
title: Fix the error message on Security & Operations dashboard by fixing the API response
merge_request: 30047
author:
type: fixed
......@@ -722,7 +722,7 @@ describe OperationsController do
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty
expect(json_response['duplicate']).to be_empty
expect(json_response['invalid']).to contain_exactly('', '-1', '-2')
expect(json_response['invalid']).to contain_exactly(0, -1, -2)
user.reload
expect(user.ops_dashboard_projects).to be_empty
......
......@@ -107,7 +107,7 @@ describe Security::ProjectsController do
expect(json_response).to eq({
'added' => [],
'duplicate' => [],
'invalid' => ['-1']
'invalid' => [-1]
})
end
end
......
......@@ -17,10 +17,7 @@
"invalid": {
"type": "array",
"items": {
"oneOf": [
{ "type": "string" },
{ "type": "null" }
]
"items": { "type": "integer" }
}
}
},
......
......@@ -57,15 +57,6 @@ describe Dashboard::Projects::CreateService do
end
end
end
context 'with invalid project ids' do
let(:input) { [nil, -1, '-1', :symbol] }
let(:output) { [] }
it 'does not add invalid project ids' do
expect(result).to eq(expected_result(invalid_project_ids: input.map(&:to_s)))
end
end
end
private
......
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