Fix deprecation warning for :unprocessable_entity in scaffold-generated tests with Rack 3.2 #2860
+29
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This Pull Request updates the
scaffoldandscaffold_controllertemplates to resolve the following warning that occurs when running the generated tests.Fix #2859
Details
It updates the
scaffoldandscaffold_controllertemplates for the invalid params cases in#create/#updatewithin request specs and controller specs.This change modifies lines like
expect(response).to have_http_status(:unprocessable_entity)in the following kind of code:For rack 3.1 and higher, this change uses
:unprocessable_contentinstead of:unprocessable_entity.For rack 3.0 and below, it continues to use
:unprocessable_entity.This is because
:unprocessable_contentwas introduced in rack 3.1:rack/rack#2137
The symbol selection between
:unprocessable_entityand:unprocessable_contentis handled usingRack::Utils::SYMBOL_TO_STATUS_CODE.key(422).The behavior of
Rack::Utils::SYMBOL_TO_STATUS_CODE.key(422)varies depending on the rack version:The code for
Rack::Utils::SYMBOL_TO_STATUS_CODEcan be found here:https://github.com/rack/rack/blob/79d6820b73d9084a60ec1f9912e3ab00439bd5d3/lib/rack/utils.rb#L564-L566