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

后端 未结 12 1646
感情败类
感情败类 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:44

    Version for Rails 5:

    post :create, body: '{"foo": "bar", "bool": true}'
    

    See here - body string parameter is treated as raw request body.

提交回复
热议问题