-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Rack::Lint to
ActionDispatch::RemoteIp
tests
To ensure Rails is and remains compliant with [the Rack 3 spec](https://github.com/rack/rack/blob/6d16306192349e665e4ec820a9bfcc0967009b6a/UPGRADE-GUIDE.md) we can add `Rack::Lint` to the Rails middleware tests. This adds additional test coverage to `ActionDispatch::RemoteIp` to validate that its input and output follow the Rack SPEC. The only code testing this middleware are the ones for `ActionDispatch::Request`. Several changes were required to make the tests pass: - `CONTENT_LENGTH` must be a string - `SERVER_PORT` must be a string - `HTTP_HOST` must be a string - `rack.input` must be an IO object, with ASCII-8BIT encoding - By leveraging `Rack::MockRequest`, we can pass the symbol :input, and the string value, and it will be converted to an IO object with the correct encoding. - See [definition here](https://github.com/rack/rack/blob/444dc8a130663159ed490f25948b73ff9b5fbba0/lib/rack/mock_request.rb#L89-L97) - using `Rack::MockRequest` also means that any symbol keys being passed to setup the env, will be discarded. [Only string keys are copied.]https://github.com/rack/rack/blob/444dc8a130663159ed490f25948b73ff9b5fbba0/lib/rack/mock_request.rb#L156
- Loading branch information
1 parent
ad790cb
commit 613e8fd
Showing
1 changed file
with
34 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters