A Product Test Fixture

Finish learning how to add a button for adding products to the cart.

We'll cover the following

A test fixture

We changed the function of our controller, so we know that we need to update the corresponding functional test.

For starters, we only need to pass a product ID on the call to post. Next, we have to deal with the fact that we’re no longer redirecting to the line items page. We’re instead redirecting to the cart, where the cart ID is internal state data residing in a cookie. Because this is an integration test, we should focus on what users see after following the redirect rather than focusing on how the code is implemented. They should see a page with a heading identifying that they’re looking at a cart with a list item corresponding to the product they added.

We do this by updating test/controllers/line_items_controller_test.rb:

Get hands-on with 1200+ tech skills courses.