Rails functional test: sending URL query parameters in POST request

前端 未结 5 1490
栀梦
栀梦 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:44

    The 2nd argument to post is a hash of all the params you'll receive in the controller. Just do this:

    post :create, collection: { name: 'New Collection' }, more_params: 'stuff', and_so_on: 'things'
    

    Those params will be available in the controller:

    params[:and_so_on] == 'things'
    

提交回复
热议问题