Skip to content
This repository was archived by the owner on Jun 2, 2021. It is now read-only.

Commit 2d0d5aa

Browse files
committed
use bad_request instead of invalid_request
- invalid_request will have it's argument's swallowed thus throwing away the custom message [#175366070](https://www.pivotaltracker.com/story/show/175366070)
1 parent 5b0ba69 commit 2d0d5aa

5 files changed

Lines changed: 7 additions & 7 deletions

File tree

app/controllers/v3/app_manifests_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def compound_error!(error_messages)
7070
def validate_content_type!
7171
if !request_content_type_is_yaml?
7272
logger.error("Context-type isn't yaml: #{request.content_type}")
73-
invalid_request!('Content-Type must be yaml')
73+
bad_request!('Content-Type must be yaml')
7474
end
7575
end
7676

@@ -81,7 +81,7 @@ def request_content_type_is_yaml?
8181
def parsed_app_manifest_params
8282
parsed_application = parsed_yaml['applications'] && parsed_yaml['applications'].first
8383

84-
raise invalid_request!('Invalid app manifest') unless parsed_application.present?
84+
raise bad_request!('Invalid app manifest') unless parsed_application.present?
8585

8686
parsed_application
8787
end

app/controllers/v3/space_manifests_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def compound_error!(error_messages)
8383
def validate_content_type!
8484
if !request_content_type_is_yaml?
8585
logger.error("Content-type isn't yaml: #{request.content_type}")
86-
invalid_request!('Content-Type must be yaml')
86+
bad_request!('Content-Type must be yaml')
8787
end
8888
end
8989

spec/request/space_manifests_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@
669669
parsed_response = MultiJson.load(last_response.body)
670670

671671
expect(last_response).to have_status_code(400)
672-
expect(parsed_response['errors'].first['detail']).to eq('The request is invalid')
672+
expect(parsed_response['errors'].first['detail']).to eq('Bad request: Content-Type must be yaml')
673673
end
674674
end
675675

@@ -692,7 +692,7 @@
692692
parsed_response = MultiJson.load(last_response.body)
693693

694694
expect(last_response).to have_status_code(400)
695-
expect(parsed_response['errors'].first['detail']).to eq('The request is invalid')
695+
expect(parsed_response['errors'].first['detail']).to eq('Bad request: Content-Type must be yaml')
696696
end
697697
end
698698

spec/unit/controllers/v3/app_manifests_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
post :apply_manifest, params: { guid: app_model.guid }, body: request_body.to_yaml
149149
expect(response.status).to eq(400)
150150
# Verify we're getting the InvalidError we're expecting
151-
expect(CloudController::Errors::ApiError).to have_received(:new_from_details).with('InvalidRequest', 'Content-Type must be yaml').exactly :once
151+
expect(CloudController::Errors::ApiError).to have_received(:new_from_details).with('BadRequest', 'Content-Type must be yaml').exactly :once
152152
end
153153
end
154154
end

spec/unit/controllers/v3/space_manifests_controller_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@
205205
post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml
206206
expect(response.status).to eq(400)
207207
# Verify we're getting the InvalidError we're expecting
208-
expect(CloudController::Errors::ApiError).to have_received(:new_from_details).with('InvalidRequest', 'Content-Type must be yaml').exactly :once
208+
expect(CloudController::Errors::ApiError).to have_received(:new_from_details).with('BadRequest', 'Content-Type must be yaml').exactly :once
209209
end
210210
end
211211

0 commit comments

Comments
 (0)