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 ...@@ -31,9 +31,9 @@ module Dashboard
end end
def find_invalid_ids(projects_to_add, project_ids) 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 end
def add_projects(projects) 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 ...@@ -722,7 +722,7 @@ describe OperationsController do
expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee') expect(json_response).to match_schema('dashboard/operations/add', dir: 'ee')
expect(json_response['added']).to be_empty expect(json_response['added']).to be_empty
expect(json_response['duplicate']).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 user.reload
expect(user.ops_dashboard_projects).to be_empty expect(user.ops_dashboard_projects).to be_empty
......
...@@ -107,7 +107,7 @@ describe Security::ProjectsController do ...@@ -107,7 +107,7 @@ describe Security::ProjectsController do
expect(json_response).to eq({ expect(json_response).to eq({
'added' => [], 'added' => [],
'duplicate' => [], 'duplicate' => [],
'invalid' => ['-1'] 'invalid' => [-1]
}) })
end end
end end
......
...@@ -17,10 +17,7 @@ ...@@ -17,10 +17,7 @@
"invalid": { "invalid": {
"type": "array", "type": "array",
"items": { "items": {
"oneOf": [ "items": { "type": "integer" }
{ "type": "string" },
{ "type": "null" }
]
} }
} }
}, },
......
...@@ -57,15 +57,6 @@ describe Dashboard::Projects::CreateService do ...@@ -57,15 +57,6 @@ describe Dashboard::Projects::CreateService do
end end
end 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 end
private 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