How do you specify POST params in a Rails test?

后端 未结 2 782
灰色年华
灰色年华 2021-01-31 18:27

Working with Test::Unit and Shoulda. Trying to test Users.create. My understanding is that Rails forms send params for an object like this:

user[ema         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-31 19:14

    post :create, {:post => {}, :user => {:email => 'abc@abcd'} }

    In this case params[:post] is {}, params[:user] is {:email => 'abc@abcd'}, params[:user][:email] is 'abc@abcd'.

    post :create, {:post => {:user => {:email => 'abc@abcd'} } }

    In this case params[:post][:user][:email] is 'abc@abcd'

提交回复
热议问题