Skip to content

Instantly share code, notes, and snippets.

@apotonick
Last active February 5, 2022 14:09
Show Gist options
  • Save apotonick/3f3f296452f78930cf18bc39caa26f81 to your computer and use it in GitHub Desktop.
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)
# 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