How to send raw post data in a Rails functional test?

后端 未结 12 1539
感情败类
感情败类 2020-12-13 12:07

I\'m looking to send raw post data (e.g. unparamaterized JSON) to one of my controllers for testing:

class LegacyOrderUpdateControllerTest < ActionControl         


        
12条回答
  •  有刺的猬
    2020-12-13 12:41

    In rails, 5.1 the following work for me when doing a delete request that needed data in the body:

    delete your_app_url, as: :json, env: {
       "RAW_POST_DATA" =>  {"a_key" => "a_value"}.to_json
    }
    

    NOTE: This only works when doing an Integration test.

提交回复
热议问题