From 978ef20994996fc43c94dd4c0ac72bd1aaca4480 Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Mon, 15 Dec 2025 14:32:27 +0100 Subject: [PATCH 1/9] Rack 3 update: Replace :unprocessable_entity with :unprocessable_content --- .../v3/app_features_controller_spec.rb | 2 +- .../controllers/v3/apps_controller_spec.rb | 66 +++++++++---------- .../v3/buildpacks_controller_spec.rb | 14 ++-- .../controllers/v3/builds_controller_spec.rb | 32 ++++----- .../v3/deployments_controller_spec.rb | 30 ++++----- .../v3/droplets_controller_spec.rb | 14 ++-- .../v3/feature_flags_controller_spec.rb | 4 +- .../v3/isolation_segments_controller_spec.rb | 20 +++--- .../v3/organizations_controller_spec.rb | 20 +++--- .../v3/packages_controller_spec.rb | 48 +++++++------- .../v3/processes_controller_spec.rb | 12 ++-- .../v3/resource_matches_controller_spec.rb | 2 +- .../v3/revisions_controller_spec.rb | 2 +- .../v3/sidecars_controller_spec.rb | 2 +- .../v3/space_manifests_controller_spec.rb | 18 ++--- .../controllers/v3/spaces_controller_spec.rb | 26 ++++---- .../controllers/v3/stacks_controller_spec.rb | 14 ++-- .../controllers/v3/tasks_controller_spec.rb | 22 +++---- 18 files changed, 174 insertions(+), 174 deletions(-) diff --git a/spec/unit/controllers/v3/app_features_controller_spec.rb b/spec/unit/controllers/v3/app_features_controller_spec.rb index 8cc85b87466..9991fe2ecb1 100644 --- a/spec/unit/controllers/v3/app_features_controller_spec.rb +++ b/spec/unit/controllers/v3/app_features_controller_spec.rb @@ -148,7 +148,7 @@ patch :update, params: { app_guid: app_model.guid, name: 'ssh' }, as: :json end.not_to(change { app_model.reload.values }) - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message('Enabled must be a boolean') end end diff --git a/spec/unit/controllers/v3/apps_controller_spec.rb b/spec/unit/controllers/v3/apps_controller_spec.rb index 26c30bc185c..5751936f7b8 100644 --- a/spec/unit/controllers/v3/apps_controller_spec.rb +++ b/spec/unit/controllers/v3/apps_controller_spec.rb @@ -218,7 +218,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -232,7 +232,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'ya done goofed' end @@ -253,7 +253,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/label [\w\s]+ error/) end @@ -276,7 +276,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/annotation [\w\s]+ error/) end @@ -331,7 +331,7 @@ it 'responds with 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 1/) end end @@ -393,7 +393,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'must be an existing admin buildpack or a valid git URI' end @@ -411,7 +411,7 @@ it 'raises an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Lifecycle data must be an object' end @@ -432,7 +432,7 @@ it 'raises an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "Lifecycle Unknown field(s): 'foo'" end @@ -450,7 +450,7 @@ it 'raises an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Lifecycle data must be an object' end @@ -603,7 +603,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -678,7 +678,7 @@ it 'returns a 422' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to match(/Metadata [\w\s]+ error/) end @@ -713,7 +713,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('must be an existing admin buildpack or a valid git URI') end @@ -799,7 +799,7 @@ patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json expect(response.body).to include 'UnprocessableEntity' - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('Stack') end end @@ -839,7 +839,7 @@ it 'raises an error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('Lifecycle data must be an object') end @@ -856,7 +856,7 @@ it 'raises an error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('Lifecycle type cannot be changed') end @@ -877,7 +877,7 @@ it 'raises an error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('Lifecycle type cannot be changed') end @@ -911,7 +911,7 @@ it 'raises an error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('Lifecycle data must be an object') end @@ -934,7 +934,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/label [\w\s]+ error/) end @@ -957,7 +957,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/annotation [\w\s]+ error/) end @@ -1021,7 +1021,7 @@ it 'responds with 422' do patch :update, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 1/) end end @@ -1165,7 +1165,7 @@ response_body = parsed_body expect(response_body['errors'].first['title']).to eq 'CF-UnprocessableEntity' expect(response_body['errors'].first['detail']).to eq 'Assign a droplet before starting this app.' - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -1190,7 +1190,7 @@ response_body = parsed_body expect(response_body['errors'].first['title']).to eq 'CF-UnprocessableEntity' - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -1312,7 +1312,7 @@ it 'returns an UnprocessableEntity error' do put :stop, params: { guid: app_model.guid }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1406,7 +1406,7 @@ response_body = parsed_body expect(response_body['errors'].first['title']).to eq 'CF-UnprocessableEntity' expect(response_body['errors'].first['detail']).to eq 'Assign a droplet before starting this app.' - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -1468,7 +1468,7 @@ post :restart, params: { guid: app_model.guid }, as: :json response_body = parsed_body - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response_body['errors'].first['title']).to eq 'CF-UnprocessableEntity' expect(response_body['errors'].first['detail']).to eq 'Ahhh!' end @@ -2063,7 +2063,7 @@ it 'returns a validation error' do patch :update_environment_variables, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'PORT' end @@ -2085,7 +2085,7 @@ it 'returns a validation error' do patch :update_environment_variables, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include "Non-string value in environment variable for key 'hashes_not_allowed'" end end @@ -2124,7 +2124,7 @@ it 'returns a 422' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Unable to assign current droplet. Ensure the droplet exists and belongs to this app.' end @@ -2136,7 +2136,7 @@ it 'returns a 422' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Current droplet cannot be removed. Replace it with a preferred droplet.' end @@ -2149,7 +2149,7 @@ it 'returns a 422' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Unable to assign current droplet. Ensure the droplet exists and belongs to this app.' end @@ -2161,7 +2161,7 @@ it 'returns a 422' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Unable to assign current droplet. Ensure the droplet exists and belongs to this app.' end @@ -2185,7 +2185,7 @@ it 'returns an UnprocessableEntity error' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -2199,7 +2199,7 @@ it 'returns an UnprocessableEntity error' do put :assign_current_droplet, params: { guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Unable to assign current droplet while the app has a deployment in progress. Wait for the deployment to complete or cancel it.' end diff --git a/spec/unit/controllers/v3/buildpacks_controller_spec.rb b/spec/unit/controllers/v3/buildpacks_controller_spec.rb index 89fcc22444f..b5412b1c008 100644 --- a/spec/unit/controllers/v3/buildpacks_controller_spec.rb +++ b/spec/unit/controllers/v3/buildpacks_controller_spec.rb @@ -334,7 +334,7 @@ it 'returns 422' do post :create, params: params, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end it 'returns a helpful error message' do @@ -354,7 +354,7 @@ it 'returns 422' do post :create, params: params, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end it 'does not create the buildpack' do @@ -461,7 +461,7 @@ it 'returns 422' do patch :update, params: { guid: buildpack.guid, enabled: 'totally-not-a-valid-value' }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(parsed_body['errors'][0]['detail']).to include('Enabled must be a boolean') end end @@ -471,7 +471,7 @@ other_buildpack = VCAP::CloudController::Buildpack.make(stack: buildpack.stack) patch :update, params: { guid: buildpack.guid, name: other_buildpack.name }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(parsed_body['errors'][0]['detail']).to include("Buildpack with name '#{other_buildpack.name}' and an unassigned stack already exists") end end @@ -628,7 +628,7 @@ it 'returns a 422 and error message that the buildpack is locked' do post :upload, params: { guid: bp.guid, bits_path: buildpack_bits_path, bits_name: buildpack_bits_name }.merge({}), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -639,7 +639,7 @@ it 'errors' do post :upload, params: params.merge({}), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') end end @@ -650,7 +650,7 @@ it 'errors' do post :upload, params: params.merge({}), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') end end diff --git a/spec/unit/controllers/v3/builds_controller_spec.rb b/spec/unit/controllers/v3/builds_controller_spec.rb index 01d48c8180b..3f9333f4ac9 100644 --- a/spec/unit/controllers/v3/builds_controller_spec.rb +++ b/spec/unit/controllers/v3/builds_controller_spec.rb @@ -215,7 +215,7 @@ it 'returns a 422 Unprocessable Entity and an informative error message' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'Only one build can be STAGING at a time per application.' end end @@ -226,7 +226,7 @@ it 'returns a 422 Unprocessable Entity' do post :create, body: bad_request.to_json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') end @@ -242,7 +242,7 @@ it 'returns a 422 Unprocessable Entity' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to use package. Ensure that the package exists and you have access to it.') end @@ -258,7 +258,7 @@ it 'returns a 422 Unprocessable Entity' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('an error occurred') end @@ -300,7 +300,7 @@ it 'returns a 422' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -322,7 +322,7 @@ it 'returns a 422' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -439,7 +439,7 @@ it 'raises a 422' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -508,7 +508,7 @@ it 'raises a 422' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -601,7 +601,7 @@ it 'returns 422 Unprocessable' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include("space's memory limit exceeded") expect(response.body).to include('helpful message') end @@ -617,7 +617,7 @@ it 'returns 422 Unprocessable' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include("organization's memory limit exceeded") expect(response.body).to include('helpful message') end @@ -631,7 +631,7 @@ it 'returns 422 Unprocessable' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('disk limit exceeded') end end @@ -646,7 +646,7 @@ it 'returns 422 Unprocessable' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include("space's log rate limit exceeded") expect(response.body).to include('helpful message') end @@ -662,7 +662,7 @@ it 'returns 422 Unprocessable' do post :create, params: req_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include("organization's log rate limit exceeded") expect(response.body).to include('helpful message') end @@ -727,7 +727,7 @@ it 'returns the correct error message' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to use package. Ensure that the package exists and you have access to it.') end @@ -740,7 +740,7 @@ it 'returns the correct error message' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to use package. Ensure that the package exists and you have access to it.') end @@ -813,7 +813,7 @@ it 'returns 422 with invalid metadata' do patch :update, params: { guid: build.guid, metadata: { annotations: { '' => 'stop', '*this*' => 'stuff' } } }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end context 'when the build\'s package has been deleted' do diff --git a/spec/unit/controllers/v3/deployments_controller_spec.rb b/spec/unit/controllers/v3/deployments_controller_spec.rb index 415cf15d89d..6179407742d 100644 --- a/spec/unit/controllers/v3/deployments_controller_spec.rb +++ b/spec/unit/controllers/v3/deployments_controller_spec.rb @@ -78,7 +78,7 @@ it 'returns a 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Invalid droplet. Please specify a droplet in the request or set a current droplet for the app.') end @@ -200,7 +200,7 @@ it 'returns a 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to assign current droplet. Ensure the droplet exists and belongs to this app.') end @@ -225,7 +225,7 @@ it 'returns a 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to assign current droplet. Ensure the droplet exists and belongs to this app.') end @@ -237,7 +237,7 @@ it 'returns 422 with an error message' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('Unable to use app. Ensure that the app exists and you have access to it and the organization is not suspended.') end end @@ -305,7 +305,7 @@ earlier_revision.destroy post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('The revision does not exist') end @@ -315,7 +315,7 @@ droplet.destroy post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Unable to deploy this revision, the droplet for this revision no longer exists.') end @@ -324,7 +324,7 @@ app.update(revisions_enabled: false) post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('Cannot create deployment from a revision for an app without revisions enabled') end end @@ -351,7 +351,7 @@ it 'returns 422 with an error message' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include("Cannot set both fields 'droplet' and 'revision'") end end @@ -414,7 +414,7 @@ it 'returns 422 with an error message' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('Unable to use app. Ensure that the app exists and you have access to it and the organization is not suspended.') end end @@ -677,7 +677,7 @@ post :cancel, params: { guid: deployment.guid } - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to match(/awry/) end end @@ -720,7 +720,7 @@ it 'displays an informative error' do patch :update, params: { guid: deployment.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message("labels' is not an object") end end @@ -788,7 +788,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: deployment.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/label [\w\s]+ error/) end @@ -811,7 +811,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: deployment.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/annotation [\w\s]+ error/) end @@ -861,7 +861,7 @@ it 'responds with 422' do patch :update, params: { guid: deployment.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'Failed to add 2 annotations because it would exceed maximum of 1' end end @@ -884,7 +884,7 @@ it 'responds with 422' do patch :update, params: { guid: deployment.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'Failed to add 2 labels because it would exceed maximum of 1' end end diff --git a/spec/unit/controllers/v3/droplets_controller_spec.rb b/spec/unit/controllers/v3/droplets_controller_spec.rb index e00d021357c..c197eda0b75 100644 --- a/spec/unit/controllers/v3/droplets_controller_spec.rb +++ b/spec/unit/controllers/v3/droplets_controller_spec.rb @@ -55,7 +55,7 @@ it 'returns a 422' do post :create, params: { source_guid: source_droplet_guid, body: { super_duper: 'bad_request' } }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -116,7 +116,7 @@ it 'returns an error' do post :create, params: { source_guid: source_droplet_guid }.merge(body: request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('boom') end end @@ -490,7 +490,7 @@ it 'displays an informative error' do patch :update, params: { guid: droplet.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message("labels' is not an object") end end @@ -573,7 +573,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: droplet.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/label [\w\s]+ error/) end @@ -596,7 +596,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { guid: droplet.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/annotation [\w\s]+ error/) end @@ -646,7 +646,7 @@ it 'responds with 422' do patch :update, params: { guid: droplet.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'Failed to add 2 annotations because it would exceed maximum of 1' end end @@ -669,7 +669,7 @@ it 'responds with 422' do patch :update, params: { guid: droplet.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'Failed to add 2 labels because it would exceed maximum of 1' end end diff --git a/spec/unit/controllers/v3/feature_flags_controller_spec.rb b/spec/unit/controllers/v3/feature_flags_controller_spec.rb index 91b86223c1d..83089012949 100644 --- a/spec/unit/controllers/v3/feature_flags_controller_spec.rb +++ b/spec/unit/controllers/v3/feature_flags_controller_spec.rb @@ -163,7 +163,7 @@ it 'returns a 422 with the error message' do patch :update, params: { name: feature_flag_name, enabled: true }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(parsed_body['errors'].first['detail']).to eq 'that did not work' end end @@ -174,7 +174,7 @@ name: feature_flag_name, bogus_param: 'bogus value' } - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'Unknown field' end end diff --git a/spec/unit/controllers/v3/isolation_segments_controller_spec.rb b/spec/unit/controllers/v3/isolation_segments_controller_spec.rb index 262f6c8c399..5157df9ca29 100644 --- a/spec/unit/controllers/v3/isolation_segments_controller_spec.rb +++ b/spec/unit/controllers/v3/isolation_segments_controller_spec.rb @@ -207,7 +207,7 @@ it 'returns a 422' do post :assign_allowed_organizations, params: { guid: isolation_segment_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -223,7 +223,7 @@ it 'does not assign any of the valid orgs and returns a 404' do post :assign_allowed_organizations, params: { guid: isolation_segment_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'bogus-guid' expect(response.body).not_to include org1.guid @@ -351,7 +351,7 @@ it 'returns a 422' do post :create, body: request_body - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -360,7 +360,7 @@ VCAP::CloudController::IsolationSegmentModel.make(name: 'some-name') post :create, params: request_body - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end end @@ -545,7 +545,7 @@ it 'returns a 422' do put :update, params: { guid: isolation_segment_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -556,7 +556,7 @@ it 'returns a 422' do put :update, params: { guid: isolation_segment_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end @@ -565,7 +565,7 @@ it 'returns a 422' do post :create, params: request_body - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end end end @@ -620,7 +620,7 @@ it 'returns a 422 UnprocessableEntity error' do delete :destroy, params: { guid: isolation_segment_model1.guid }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('Revoke the Organization entitlements for your Isolation Segment.') end @@ -679,14 +679,14 @@ it 'cannot be deleted' do delete :destroy, params: { guid: shared_segment.guid }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(VCAP::CloudController::IsolationSegmentModel.first(guid: shared_segment.guid).exists?).to be true end it 'cannot be updated via API' do put :update, params: { guid: shared_segment.guid, body: request_body }, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(shared_segment.name).to eq(original_name) end end diff --git a/spec/unit/controllers/v3/organizations_controller_spec.rb b/spec/unit/controllers/v3/organizations_controller_spec.rb index 503a10baacb..94a025704e3 100644 --- a/spec/unit/controllers/v3/organizations_controller_spec.rb +++ b/spec/unit/controllers/v3/organizations_controller_spec.rb @@ -83,7 +83,7 @@ context 'when there is a message validation failure' do it 'displays an informative error' do post :create, params: { name: '' }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message("Name can't be blank") end end @@ -97,7 +97,7 @@ it 'responds with 422' do post :create, params: { name: }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message("Organization '#{name}' already exists.") end end @@ -118,7 +118,7 @@ } }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 1/) end end @@ -448,7 +448,7 @@ org.reload error_string = "Unable to assign isolation segment with guid '#{isolation_segment.guid}'. Ensure it has been entitled to the organization." - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include(error_string) end @@ -474,7 +474,7 @@ it 'throws UnprocessableEntity error' do patch :update_default_isolation_segment, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "Unable to assign isolation segment with guid 'garbage-guid'. Ensure it has been entitled to the organization." end @@ -490,7 +490,7 @@ it 'returns 422' do patch :update_default_isolation_segment, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('bad thing happened!') end @@ -506,7 +506,7 @@ it 'returns 422' do patch :update_default_isolation_segment, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('123 must be a string') end @@ -690,7 +690,7 @@ it 'displays an informative error' do patch :update, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message('Name is too short (minimum is 1 character)') end end @@ -726,7 +726,7 @@ it 'displays an informative error' do patch :update, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/label [\w\s]+ error/) end end @@ -749,7 +749,7 @@ it 'fails with a 422' do patch :update, params: { guid: org.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 2/) end end diff --git a/spec/unit/controllers/v3/packages_controller_spec.rb b/spec/unit/controllers/v3/packages_controller_spec.rb index 4f627ea83a8..2537f217969 100644 --- a/spec/unit/controllers/v3/packages_controller_spec.rb +++ b/spec/unit/controllers/v3/packages_controller_spec.rb @@ -142,7 +142,7 @@ it 'returns a 422 Unprocessable' do post :upload, params: params.merge(guid: package.guid), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Package type must be bits.') end @@ -163,7 +163,7 @@ it 'returns a 422 UnprocessableEntity error' do post :upload, params: params.merge(guid: package.guid), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -190,7 +190,7 @@ it 'returns 422' do post :upload, params: params.merge(guid: package.guid), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -268,7 +268,7 @@ it 'returns 422' do get :download, params: { guid: package.guid } - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -282,7 +282,7 @@ it 'returns 422' do get :download, params: { guid: package.guid } - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') end end @@ -446,7 +446,7 @@ it 'fails' do patch :update, params: { guid: package.guid }.merge(message), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message('Cannot update Docker credentials for a buildpack app.') end end @@ -539,7 +539,7 @@ it 'fails' do patch :update, params: { guid: package.guid }.merge(update_message2), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end @@ -564,7 +564,7 @@ it 'displays an informative error' do patch :update, params: { guid: package.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/label [\w\s]+ error/) end end @@ -582,7 +582,7 @@ it 'displays an informative error' do patch :update, params: { guid: package.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/is greater than 5000 characters/) end end @@ -605,7 +605,7 @@ it 'fails with a 422' do patch :update, params: { guid: package.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 2/) end end @@ -1003,7 +1003,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "must be one of 'bits, docker'" end @@ -1015,7 +1015,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1028,7 +1028,7 @@ it 'returns 422' do post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1039,7 +1039,7 @@ it 'returns 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message('Cannot create bits package for a Docker app.') end @@ -1067,7 +1067,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1080,7 +1080,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1124,7 +1124,7 @@ it 'returns 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message('Cannot create Docker package for a buildpack app.') end @@ -1148,7 +1148,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: metadata_request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/label [\w\s]+ error/) end @@ -1168,7 +1168,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: metadata_request_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response).to have_error_message(/annotation [\w\s]+ error/) end @@ -1252,7 +1252,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { source_guid: original_package.guid }.merge(relationship_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1279,7 +1279,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { source_guid: original_package.guid }.merge(relationship_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1303,7 +1303,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { source_guid: 'bogus package guid' }.merge(relationship_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1314,7 +1314,7 @@ it 'returns a 422 UnprocessableEntity error' do post :create, params: { source_guid: original_package.guid }.merge(relationship_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -1327,7 +1327,7 @@ it 'returns 422' do post :create, params: { source_guid: original_package.guid }.merge(relationship_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'ruh roh' end diff --git a/spec/unit/controllers/v3/processes_controller_spec.rb b/spec/unit/controllers/v3/processes_controller_spec.rb index 7b66741bf0e..4ae9f35d71e 100644 --- a/spec/unit/controllers/v3/processes_controller_spec.rb +++ b/spec/unit/controllers/v3/processes_controller_spec.rb @@ -351,7 +351,7 @@ it 'returns 422' do patch :update, params: { process_guid: process_type.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('errorz') end @@ -363,7 +363,7 @@ it 'returns 422' do patch :update, params: { process_guid: process_type.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Command must be a string') end @@ -387,7 +387,7 @@ patch :update, params: { process_guid: process.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('Cannot update this process while a deployment is in flight.') end end @@ -624,7 +624,7 @@ it 'returns 422' do put :scale, params: { process_guid: process_type.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('errorz') end @@ -661,7 +661,7 @@ it 'returns 422' do put :scale, params: { process_guid: process_type.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('UnprocessableEntity') expect(response.body).to include('Instances is not a number') end @@ -694,7 +694,7 @@ put :scale, params: { process_guid: process.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include('Cannot scale this process while a deployment is in flight.'), response.body end end diff --git a/spec/unit/controllers/v3/resource_matches_controller_spec.rb b/spec/unit/controllers/v3/resource_matches_controller_spec.rb index 880331ffde4..a2df30fc97e 100644 --- a/spec/unit/controllers/v3/resource_matches_controller_spec.rb +++ b/spec/unit/controllers/v3/resource_matches_controller_spec.rb @@ -196,7 +196,7 @@ it 'returns an error' do post :create, params: { 'wrong-key' => [] }, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end end diff --git a/spec/unit/controllers/v3/revisions_controller_spec.rb b/spec/unit/controllers/v3/revisions_controller_spec.rb index 03d214f3e03..ecf62faf9d7 100644 --- a/spec/unit/controllers/v3/revisions_controller_spec.rb +++ b/spec/unit/controllers/v3/revisions_controller_spec.rb @@ -327,7 +327,7 @@ it 'returns a 422' do patch :update, params: { revision_guid: revision.guid }.merge(update_message), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end end diff --git a/spec/unit/controllers/v3/sidecars_controller_spec.rb b/spec/unit/controllers/v3/sidecars_controller_spec.rb index 28d79e0d2f8..a9591af10aa 100644 --- a/spec/unit/controllers/v3/sidecars_controller_spec.rb +++ b/spec/unit/controllers/v3/sidecars_controller_spec.rb @@ -180,7 +180,7 @@ it 'returns 422' do post :create, params: sidecar_params, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Sidecar with name \'my_sidecar\' already exists for given app' end diff --git a/spec/unit/controllers/v3/space_manifests_controller_spec.rb b/spec/unit/controllers/v3/space_manifests_controller_spec.rb index a1f249ef666..a9740924979 100644 --- a/spec/unit/controllers/v3/space_manifests_controller_spec.rb +++ b/spec/unit/controllers/v3/space_manifests_controller_spec.rb @@ -119,7 +119,7 @@ it 'returns a 422' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end @@ -128,7 +128,7 @@ it 'returns a 422' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end @@ -149,7 +149,7 @@ it 'returns a 422 and validation errors' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) errors = parsed_body['errors'] expect(errors.size).to eq(14) def error_message(detail) @@ -200,7 +200,7 @@ def error_message(detail) it 'returns a 422' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) parsed_response = Oj.load(response.body) expect(parsed_response['errors'][0]['detail']).to match(/For application at index 0:/) end @@ -257,7 +257,7 @@ def error_message(detail) it 'returns an error' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) errors = parsed_body['errors'] expect(errors.size).to eq(1) expected_error = [ @@ -301,7 +301,7 @@ def error_message(detail) it 'returns an error' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) errors = parsed_body['errors'] expect(errors.size).to eq(1) expected_error = [ @@ -322,7 +322,7 @@ def error_message(detail) it 'returns a 422 and a useful error to the user' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) space_apply_manifest_jobs = Delayed::Job.where(Sequel.lit("handler like '%SpaceApplyManifest%'")) expect(space_apply_manifest_jobs.count).to eq 0 @@ -371,7 +371,7 @@ def error_message(detail) it 'returns an error' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) errors = parsed_body['errors'] expect(errors.size).to eq(1) expected_error = [{ @@ -750,7 +750,7 @@ def error_message(detail) it 'returns manifest errors associated with their apps' do post :apply_manifest, params: { guid: space.guid }, body: request_body.to_yaml, as: :yaml - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) errors = parsed_body['errors'] expect(errors.size).to eq(2) processed_errors = errors.map { |h| h.except('test_mode_info') } diff --git a/spec/unit/controllers/v3/spaces_controller_spec.rb b/spec/unit/controllers/v3/spaces_controller_spec.rb index f11be5665d4..5c83e206aa9 100644 --- a/spec/unit/controllers/v3/spaces_controller_spec.rb +++ b/spec/unit/controllers/v3/spaces_controller_spec.rb @@ -473,7 +473,7 @@ it 'returns a 422' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Invalid organization. Ensure the organization exists and you have access to it.' end @@ -484,7 +484,7 @@ set_current_user(user_without_role) post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Invalid organization. Ensure the organization exists and you have access to it.' end @@ -496,7 +496,7 @@ post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "Unknown field(s): 'invalid'" end @@ -508,7 +508,7 @@ it 'returns a 422 and a helpful error' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "Name can't be blank" end @@ -524,7 +524,7 @@ it 'returns a 422 and a helpful error' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Name must be unique' end @@ -549,7 +549,7 @@ it 'displays an informative error' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/is greater than 5000 characters/) end end @@ -578,7 +578,7 @@ it 'fails with a 422' do post :create, params: request_body, as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 1/) end end @@ -682,7 +682,7 @@ it 'fails' do patch :update, params: { guid: space.guid }.merge(update_message), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end @@ -729,7 +729,7 @@ it 'displays an informative error' do patch :update, params: { guid: space.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message('label key error') end end @@ -747,7 +747,7 @@ it 'displays an informative error' do patch :update, params: { guid: space.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/is greater than 5000 characters/) end end @@ -770,7 +770,7 @@ it 'fails with a 422' do patch :update, params: { guid: space.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 2/) end end @@ -868,7 +868,7 @@ it 'does not assign an isolation segment to a space in a different org' do patch :update_isolation_segment, params: { guid: space3.guid }.merge(update_message), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include( "Unable to assign isolation segment with guid '#{isolation_segment_model.guid}'. Ensure it has been entitled to the organization that this space belongs to." ) @@ -881,7 +881,7 @@ it 'raises an error' do patch :update_isolation_segment, params: { guid: space1.guid }.merge(update_message), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response.body).to include( "Unable to assign isolation segment with guid 'potato'. Ensure it has been entitled to the organization that this space belongs to." ) diff --git a/spec/unit/controllers/v3/stacks_controller_spec.rb b/spec/unit/controllers/v3/stacks_controller_spec.rb index 196ea25112f..59fd7a9934f 100644 --- a/spec/unit/controllers/v3/stacks_controller_spec.rb +++ b/spec/unit/controllers/v3/stacks_controller_spec.rb @@ -158,7 +158,7 @@ it 'returns a 422 with the error message' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(parsed_body['errors'].first['detail']).to eq 'Name can\'t be blank' end end @@ -173,7 +173,7 @@ it 'returns a 422 with the error message' do post :create, params: req_body, as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(parsed_body['errors'].first['detail']).to eq 'that did not work' end end @@ -284,7 +284,7 @@ it 'returns 422' do delete :destroy, params: { guid: stack.guid } - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content end it 'returns 10008 UnprocessableEntity' do @@ -405,7 +405,7 @@ it 'fails' do patch :update, params: { guid: stack.guid }.merge(update_message2), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) end end @@ -430,7 +430,7 @@ it 'displays an informative error' do patch :update, params: { guid: stack.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/label [\w\s]+ error/) end end @@ -448,7 +448,7 @@ it 'displays an informative error' do patch :update, params: { guid: stack.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/is greater than 5000 characters/) end end @@ -471,7 +471,7 @@ it 'fails with a 422' do patch :update, params: { guid: stack.guid }.merge(request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 2/) end end diff --git a/spec/unit/controllers/v3/tasks_controller_spec.rb b/spec/unit/controllers/v3/tasks_controller_spec.rb index 939a7474f74..f2898362b1c 100644 --- a/spec/unit/controllers/v3/tasks_controller_spec.rb +++ b/spec/unit/controllers/v3/tasks_controller_spec.rb @@ -167,7 +167,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: { app_guid: app_model.guid }.merge(metadata_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include('label key error') end @@ -193,7 +193,7 @@ it 'returns an UnprocessableEntity error' do post :create, params: { app_guid: app_model.guid }.merge(metadata_request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'annotation key error' end @@ -248,7 +248,7 @@ it 'responds with 422' do post :create, params: { app_guid: app_model.guid }.merge(metadata_request_body), as: :json - expect(response).to have_http_status(:unprocessable_entity) + expect(response).to have_http_status(:unprocessable_content) expect(response).to have_error_message(/exceed maximum of 1/) end end @@ -260,7 +260,7 @@ post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include "Unknown field(s): 'invalid'" end @@ -273,7 +273,7 @@ post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'command must be shorter than 7 characters' end @@ -283,7 +283,7 @@ it 'returns a useful error message' do post :create, params: { app_guid: app_model.guid } - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -303,7 +303,7 @@ it 'returns a 422 and a helpful error' do post :create, params: { app_guid: app_model.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'Task must have a droplet. Specify droplet or assign current droplet to app.' end @@ -621,7 +621,7 @@ it 'returns a 422 Unprocessable' do put :cancel, params: { task_guid: task.guid } - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include('sad trombone') end end @@ -673,7 +673,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { task_guid: task.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' end end @@ -692,7 +692,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { task_guid: task.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'label key error' end @@ -715,7 +715,7 @@ it 'returns an UnprocessableEntity error' do patch :update, params: { task_guid: task.guid }.merge(request_body), as: :json - expect(response).to have_http_status :unprocessable_entity + expect(response).to have_http_status :unprocessable_content expect(response.body).to include 'UnprocessableEntity' expect(response.body).to include 'annotation key error' end From d8fb6bc779ae401507a980968446cac267427096 Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Mon, 15 Dec 2025 15:57:41 +0100 Subject: [PATCH 2/9] Rack::Test update: Rename response header -> headers --- .../internal/download_droplets_controller_spec.rb | 6 +++--- spec/unit/controllers/runtime/apps_controller_spec.rb | 2 +- .../controllers/runtime/buildpack_bits_controller_spec.rb | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/unit/controllers/internal/download_droplets_controller_spec.rb b/spec/unit/controllers/internal/download_droplets_controller_spec.rb index ce5cc49ab36..2150498c0d3 100644 --- a/spec/unit/controllers/internal/download_droplets_controller_spec.rb +++ b/spec/unit/controllers/internal/download_droplets_controller_spec.rb @@ -64,7 +64,7 @@ def upload_droplet get "/internal/v2/droplets/#{process.guid}/#{process.droplet_checksum}/download" expect(last_response).to be_redirect - expect(last_response.header['Location']).to eq(expected_redirect) + expect(last_response.headers['Location']).to eq(expected_redirect) end end @@ -250,7 +250,7 @@ def upload_droplet(target_droplet=droplet) get "/internal/v4/droplets/#{process.guid}/#{process.droplet_checksum}/download" expect(last_response).to be_redirect - expect(last_response.header['Location']).to eq('http://example.com/somewhere/else') + expect(last_response.headers['Location']).to eq('http://example.com/somewhere/else') end context 'when using with a revision' do @@ -271,7 +271,7 @@ def upload_droplet(target_droplet=droplet) get "/internal/v4/droplets/#{process.guid}/#{new_droplet.checksum}/download" expect(last_response).to be_redirect - expect(last_response.header['Location']).to eq('http://example.com/correct/droplet') + expect(last_response.headers['Location']).to eq('http://example.com/correct/droplet') end end end diff --git a/spec/unit/controllers/runtime/apps_controller_spec.rb b/spec/unit/controllers/runtime/apps_controller_spec.rb index 46f3bb1200e..300f736f34b 100644 --- a/spec/unit/controllers/runtime/apps_controller_spec.rb +++ b/spec/unit/controllers/runtime/apps_controller_spec.rb @@ -1818,7 +1818,7 @@ def delete_app it 'lets the user download the droplet' do get "/v2/apps/#{process.app.guid}/droplet/download", Oj.dump({}) expect(last_response).to be_redirect - expect(last_response.header['Location']).to eq('http://example.com/somewhere/else') + expect(last_response.headers['Location']).to eq('http://example.com/somewhere/else') end it 'returns an error for non-existent apps' do diff --git a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb index 8f3cab4edfd..a18fb1e7248 100644 --- a/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb +++ b/spec/unit/controllers/runtime/buildpack_bits_controller_spec.rb @@ -316,7 +316,7 @@ module VCAP::CloudController authorize(staging_user, staging_password) get "/v2/buildpacks/#{test_buildpack.guid}/download" expect(last_response.status).to eq(302) - expect(last_response.header['Location']).to match(/cc-buildpacks/) + expect(last_response.headers['Location']).to match(/cc-buildpacks/) end it 'returns 404 for missing bits' do From c615b83e3ab9798ffbbd9ca0ed928c4ef1a150de Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Mon, 15 Dec 2025 15:59:41 +0100 Subject: [PATCH 3/9] Rack 3 / Sinatra 4 upgrade: Rewind body before reading --- app/controllers/internal/staging_completion_controller.rb | 3 ++- app/controllers/internal/task_completion_controller.rb | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/internal/staging_completion_controller.rb b/app/controllers/internal/staging_completion_controller.rb index a3867348faf..06e9546f088 100644 --- a/app/controllers/internal/staging_completion_controller.rb +++ b/app/controllers/internal/staging_completion_controller.rb @@ -121,7 +121,8 @@ def prometheus_updater attr_reader :stagers def read_body - payload = body.read + request.body.rewind + payload = request.body.read Oj.load(payload, symbol_keys: true) rescue StandardError => e logger.error('diego.staging.parse-error', payload: payload, error: e.to_s) diff --git a/app/controllers/internal/task_completion_controller.rb b/app/controllers/internal/task_completion_controller.rb index 54c6c0b6dc3..138c4aa7769 100644 --- a/app/controllers/internal/task_completion_controller.rb +++ b/app/controllers/internal/task_completion_controller.rb @@ -25,7 +25,8 @@ def complete_task(task_guid, task_response) end def read_body - payload = body.read + request.body.rewind + payload = request.body.read Oj.load(payload, symbol_keys: true) rescue StandardError => e logger.error('diego.task.parse-error', payload: payload, error: e.to_s) From 2c6459c9ecc8bea1049d818c44ce97ae738272b8 Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 11:24:14 +0100 Subject: [PATCH 4/9] Sinatra 4 expects a real IO-like object --- lib/cloud_controller/logs/steno_io.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/cloud_controller/logs/steno_io.rb b/lib/cloud_controller/logs/steno_io.rb index 0381da76296..a72359ea6d7 100644 --- a/lib/cloud_controller/logs/steno_io.rb +++ b/lib/cloud_controller/logs/steno_io.rb @@ -8,7 +8,24 @@ def write(str) @logger.log(@level, str) end + def puts(*args) + args.each { |a| write("#{a}\n") } + nil + end + + def flush + nil + end + + def close + nil + end + def sync true end + + def to_s + @logger.name + end end From ca7b6b3ea417f3f8b483677f19ceb65292885780 Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 13:28:12 +0100 Subject: [PATCH 5/9] Rack 3 update: Disable host authorization feature --- lib/sinatra/vcap.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/sinatra/vcap.rb b/lib/sinatra/vcap.rb index cbee4acae2b..e9ef9729679 100644 --- a/lib/sinatra/vcap.rb +++ b/lib/sinatra/vcap.rb @@ -70,6 +70,7 @@ def vcap_configure(opts={}) set(:show_exceptions, false) set(:raise_errors, false) set(:dump_errors, false) + set(:host_authorization, permitted_hosts: []) end configure :development do From 45494898ab91149dbb55a93d69f7f4776e17feab Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 13:28:40 +0100 Subject: [PATCH 6/9] Rack 3 update: Fix headers handling --- spec/request/packages_spec.rb | 2 +- spec/unit/controllers/v3/application_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/request/packages_spec.rb b/spec/request/packages_spec.rb index 3d8c0c90d02..81a05c313fd 100644 --- a/spec/request/packages_spec.rb +++ b/spec/request/packages_spec.rb @@ -1194,7 +1194,7 @@ expect(last_response.status).to eq(202) expect(last_response.body).to eq('') - expect(last_response.header['Location']).to match(%r{jobs/[a-fA-F0-9-]+}) + expect(last_response.headers['Location']).to match(%r{jobs/[a-fA-F0-9-]+}) execute_all_jobs(expected_successes: 2, expected_failures: 0) get "/v3/packages/#{guid}", {}, user_header expect(last_response.status).to eq(404) diff --git a/spec/unit/controllers/v3/application_controller_spec.rb b/spec/unit/controllers/v3/application_controller_spec.rb index 1d40b81309a..f7410e23a27 100644 --- a/spec/unit/controllers/v3/application_controller_spec.rb +++ b/spec/unit/controllers/v3/application_controller_spec.rb @@ -362,7 +362,7 @@ def warnings_incorrect_type routes.draw { get 'multiple_warnings' => 'anonymous#multiple_warnings' } get :multiple_warnings expect(response).to have_http_status(:ok) - warnings = response.headers['X-Cf-Warnings'].split(',').map { |w| CGI.unescape(w) } + warnings = response.headers['X-Cf-Warnings'].map { |w| CGI.unescape(w) } expect(warnings).to eq([ 'warning,a', 'wa,rning b', From 4bdf7ada7696fa8f778c255c7c16375368ee34ad Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 15:43:00 +0100 Subject: [PATCH 7/9] Rack 3 update: Call rewind on request body --- app/controllers/internal/app_crashed_controller.rb | 3 ++- app/controllers/internal/app_readiness_changed_controller.rb | 3 ++- app/controllers/internal/app_rescheduling_controller.rb | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/controllers/internal/app_crashed_controller.rb b/app/controllers/internal/app_crashed_controller.rb index ebb90c66599..98066bfb769 100644 --- a/app/controllers/internal/app_crashed_controller.rb +++ b/app/controllers/internal/app_crashed_controller.rb @@ -26,7 +26,8 @@ def crashed(lrp_process_guid) private def crashed_request - payload = body.read + request.body.rewind + payload = request.body.read Oj.load(payload) rescue StandardError => e logger.error('diego.app_crashed.parse-error', payload: payload, error: e.to_s) diff --git a/app/controllers/internal/app_readiness_changed_controller.rb b/app/controllers/internal/app_readiness_changed_controller.rb index 61a93fa3419..bacc26e6ebf 100644 --- a/app/controllers/internal/app_readiness_changed_controller.rb +++ b/app/controllers/internal/app_readiness_changed_controller.rb @@ -25,7 +25,8 @@ def readiness_changed(process_guid) private def readiness_request - payload = body.read + request.body.rewind + payload = request.body.read Oj.load(payload) rescue StandardError => e logger.error('diego.app_readiness_changed.parse-error', payload: payload, error: e.to_s) diff --git a/app/controllers/internal/app_rescheduling_controller.rb b/app/controllers/internal/app_rescheduling_controller.rb index a24abb48bd3..57f162563ee 100644 --- a/app/controllers/internal/app_rescheduling_controller.rb +++ b/app/controllers/internal/app_rescheduling_controller.rb @@ -25,7 +25,8 @@ def rescheduling(process_guid) private def rescheduling_request - payload = body.read + request.body.rewind + payload = request.body.read Oj.load(payload) rescue StandardError => e logger.error('diego.app_rescheduling.parse-error', payload: payload, error: e.to_s) From d51f68c80139768eba033a349daef7c11cdd984d Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 15:43:58 +0100 Subject: [PATCH 8/9] Update to Sinatra 4.2 and Rack 3.2 --- Gemfile | 3 ++- Gemfile.lock | 34 +++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/Gemfile b/Gemfile index 7b6ae231998..c7e36f81290 100644 --- a/Gemfile +++ b/Gemfile @@ -31,7 +31,7 @@ gem 'redis' gem 'rubyzip', '>= 1.3.0' gem 'sequel', '~> 5.99' gem 'sequel_pg', require: 'sequel' -gem 'sinatra', '~> 3.2' +gem 'sinatra', '~> 4.2' gem 'sinatra-contrib' gem 'statsd-ruby', '~> 1.5.0' gem 'steno' @@ -88,6 +88,7 @@ group :test do gem 'rubocop-sequel', '~> 0.4.1' gem 'timecop' gem 'webmock', '> 2.3.1' + gem 'webrick', '~> 1.9.0' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index b96e7322d3d..c8f77bca299 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -369,17 +369,18 @@ GEM puma (7.1.0) nio4r (~> 2.0) racc (1.8.1) - rack (2.2.21) - rack-protection (3.2.0) + rack (3.2.4) + rack-protection (4.2.1) base64 (>= 0.1.0) - rack (~> 2.2, >= 2.2.4) - rack-session (1.0.2) - rack (< 3) + logger (>= 1.6.0) + rack (>= 3.0.0, < 4) + rack-session (2.1.1) + base64 (>= 0.1.0) + rack (>= 3.0.0) rack-test (2.2.0) rack (>= 1.3) - rackup (1.0.1) - rack (< 3) - webrick + rackup (2.3.1) + rack (>= 3) rails-dom-testing (2.3.0) activesupport (>= 5.0.0) minitest @@ -521,16 +522,18 @@ GEM json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - sinatra (3.2.0) + sinatra (4.2.1) + logger (>= 1.6.0) mustermann (~> 3.0) - rack (~> 2.2, >= 2.2.4) - rack-protection (= 3.2.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.2.1) + rack-session (>= 2.0.0, < 3) tilt (~> 2.0) - sinatra-contrib (3.2.0) + sinatra-contrib (4.2.1) multi_json (>= 0.0.2) mustermann (~> 3.0) - rack-protection (= 3.2.0) - sinatra (= 3.2.0) + rack-protection (= 4.2.1) + sinatra (= 4.2.1) tilt (~> 2.0) solargraph (0.57.0) backport (~> 1.2) @@ -673,7 +676,7 @@ DEPENDENCIES rubyzip (>= 1.3.0) sequel (~> 5.99) sequel_pg - sinatra (~> 3.2) + sinatra (~> 4.2) sinatra-contrib solargraph spork! @@ -686,6 +689,7 @@ DEPENDENCIES uri (~> 1.1) vmstat (~> 2.3) webmock (> 2.3.1) + webrick (~> 1.9.0) BUNDLED WITH 2.4.19 From 704da356a5647a1377f46e544ad6a4eca1d8e9aa Mon Sep 17 00:00:00 2001 From: Jochen Ehret Date: Tue, 16 Dec 2025 16:51:48 +0100 Subject: [PATCH 9/9] Rack 3 update: Patch RspecApiDocumentation module * and add unit test to check rspec_api_documentation Gem version (will fail when Gem is updated) --- spec/support/rspec_api_documentation_patch.rb | 14 ++++++++++++++ .../rspec_api_documentation_version_spec.rb | 10 ++++++++++ 2 files changed, 24 insertions(+) create mode 100644 spec/support/rspec_api_documentation_patch.rb create mode 100644 spec/unit/support/rspec_api_documentation_version_spec.rb diff --git a/spec/support/rspec_api_documentation_patch.rb b/spec/support/rspec_api_documentation_patch.rb new file mode 100644 index 00000000000..ea8b65ab883 --- /dev/null +++ b/spec/support/rspec_api_documentation_patch.rb @@ -0,0 +1,14 @@ +# Monkey patch to provide a robust read_request_body helper compatible with Rack 3 +# See: +# https://github.com/zipmark/rspec_api_documentation/pull/550 +# https://github.com/zipmark/rspec_api_documentation/issues/548 + +module RspecApiDocumentation + class ClientBase + def read_request_body + input = last_request.env['rack.input'] || StringIO.new + input.rewind + input.read + end + end +end diff --git a/spec/unit/support/rspec_api_documentation_version_spec.rb b/spec/unit/support/rspec_api_documentation_version_spec.rb new file mode 100644 index 00000000000..7a251241b87 --- /dev/null +++ b/spec/unit/support/rspec_api_documentation_version_spec.rb @@ -0,0 +1,10 @@ +require 'spec_helper' + +RSpec.describe 'rspec_api_documentation gem version' do + it 'is pinned to 6.1.0 for the monkey patch compatibility' do + spec = Gem.loaded_specs['rspec_api_documentation'] + # Ensure the gem is loaded; spec_helper requires it in init block. + expect(spec).not_to be_nil + expect(spec.version.to_s).to eq('6.1.0') + end +end