small medium large xlarge

Generic-user-small
07 Sep 2011, 15:36
Scott Herrington (6 posts)

I am struggling a bit with getting functional testing email to pass. I am getting the following two errors:

1) Error: test_received(OrderNotifierTest): ActionView::Template::Error: undefined method `title’ for nil:NilClass

2) Error: test_shipped(OrderNotifierTest): ActionView::Template::Error: undefined method `title’ for nil:NilClass

Where does these value get set for this test to pass? Do we need a fixture? assert_match /1 x Programming Ruby 1.9/, mail.body.encoded

assert_match /<td>1×<\/td>\s*<td>Programming Ruby 1.9<\/td>/, mail.body.encoded

Samr_small_pragsmall
07 Sep 2011, 23:25
Sam Ruby (634 posts)

test “shipped” has the following line:

mail = OrderNotifier.shipped(orders(:one))

@order_notifier/shipped.html.erb@ renders @line_items/_line_item.html.erb@ which contains the following line:

  <td><%= line_item.product.title %></td>

Theory: test/fixtures/line_items.yml has a line item that is in order one that doesn’t reference a valid product. At the bottom of page 89 a product with an id of ruby was added. Verify that this matches the first entry in your fixtures/line_items.yml file. See top of page 165 for what this file should look like.

Generic-user-small
08 Sep 2011, 15:16
Scott Herrington (6 posts)

That fixed the problem. I had product_id: 1 instead of product: ruby in line_items.yml. Thank you.

You must be logged in to comment