Last active
February 5, 2022 14:09
-
-
Save apotonick/3f3f296452f78930cf18bc39caa26f81 to your computer and use it in GitHub Desktop.
Setting the raw body of a POST or PATCH request in ActionDispatch::IntegrationTest (Rails 7)
This file contains hidden or 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
# If you don't want to use :params because you want to post/patch a "real" document using the request body. | |
# test file: | |
patch "/api/v2/diagrams/1", headers: {"RAW_POST_DATA" => '{"my":"json doc"}'}, as: :json | |
# to read it in a controller action | |
def update | |
document = request.body.read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment