Rails functional test: sending URL query parameters in POST request

前端 未结 5 1492
栀梦
栀梦 2021-02-19 20:55

I\'m sending a POST request in a Rails functional test like this:

post :create, collection: { name: \'New Collection\' }

collection

5条回答
  •  一整个雨季
    2021-02-19 21:52

    I assume that the controller is named CollectionsController, and its route to create action is /collections (if not, you just have to adapt the example bellow)

    And I also assume you are in a request spec

    This should work:

    post '/collections?api_key=my_key', collection: { name: 'New Collection' }
    

提交回复
热议问题