I have a rail controller defined here:
https://github.com/abonec/Simple-Store/blob/master/app/controllers/carts_controller.rb
On the cart page, the user can specify the number of lines by sending nested attributes. The parameters are as follows:
{ "cart" => { "line_items_attributes" => { "0" => { "quantity" => "2", "id" => "36" } } }, "commit" => "Update Cart", "authenticity_token" => "UdtQ+lchSKaHHkN2E1bEX00KcdGIekGjzGKgKfH05So=", "utf8"=>"\342\234\223" }
In my controller action, these parameters are saved as follows:
@cart.update_attributes(params[:cart])
But I do not know how to test this behavior in a test. @cart.attributes only generates model attributes, not nested attributes.
How can I test this behavior? How to simulate a mail request with nested attributes in my functional tests?
abonec
source share