Skip to content

Commit

Permalink
Addressed code review issue #934
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisala committed May 6, 2024
1 parent bc90148 commit a143e4e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ class DataSetSummaryController {
return
}

dataSets.each { Map dataSet ->
for (Map dataSet in dataSets) {
if (dataSet.projectId && dataSet.projectId != projectId) {
render status: HttpStatus.SC_BAD_REQUEST, text: "projectId must match the data set projectId"
render status: HttpStatus.SC_BAD_REQUEST, text: "projectId must match the projectId in all supplied data sets"
return
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,19 @@ class DataSetSummaryControllerSpec extends Specification implements ControllerUn
1 * projectService.updateDataSets(projectId, postBody.dataSets) >> [status:'ok']
response.json == ['status':'ok']
}

void "If a projectId is present in a dataSet it much match the projectId parameter in bulkUpdate"() {
setup:
String projectId = 'p1'
Map postBody = [dataSets:[[dataSetId:'d1', name:'Data set 1', projectId:'p1'], [dataSetId:'d2', name:'Data set 2', projectId:'p2']]]

when:
request.method = 'POST'
request.json = postBody
controller.bulkUpdate(projectId)

then:
0 * projectService.updateDataSets(_, _)
response.status == HttpStatus.SC_BAD_REQUEST
}
}

0 comments on commit a143e4e

Please sign in to comment.