In Rails, how do you functional test a Javascript response format?

前端 未结 9 931
攒了一身酷
攒了一身酷 2021-01-31 15:41

If your controller action looks like this:

respond_to do |format|
  format.html { raise \'Unsupported\' }
  format.js # index.js.erb
end

and yo

9条回答
  •  走了就别回头了
    2021-01-31 16:17

    Use code like this for parameters and user id, etc., notice that format option is in the same hash of other parameters like id and nested_attributes.

    put :update, {id: record.id, nested_attributes: {id: 1, name: "John"}, format: :js}, user.id
    

提交回复
热议问题