17 Jun 2013, 05:15
Generic-user-small

Richard Wilson (6 posts)

The following error is thrown when I run my functional test:

[17/34] OrderNotifierTest#test_shipped = 0.01 s         
  2) Error:
test_shipped(OrderNotifierTest):
ActionView::Template::Error: undefined method `title' for nil:NilClass
    /home/richard/projects/pickaxe/mini-projects/depot-app/app/views/line_items/_line_item.html.erb:9:in `_app_views_line_items__line_item_html_erb___1375608412970670484_69828130048560'

The error is thrown via this line in _line_item.html.erb

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

I think this is a problem with my fixture setup, but I don’t know how I would go about adding line_items to the order.

Please advise,

Richard

17 Jun 2013, 05:25
Generic-user-small

Richard Wilson (6 posts)

  1) Failure:
test_received(OrderNotifierTest) [/home/richard/projects/pickaxe/mini-projects/depot-app/test/functional/order_notifier_test.rb:9]:
Expected /1 x Programming Ruby 1.9/ to match "Dear Dave Thomas\r\n\r\nThank you for your recent order from the Pragmatic Store..\r\n\r\nYou ordered the following:\r\n\r\n\r\n\r\nWe'll send you a seperate email when your order ships..\r\n\r\nCheers!\r\n".

[17/34] OrderNotifierTest#test_shipped = 0.01 s         
  2) Failure:
test_shipped(OrderNotifierTest) [/home/richard/projects/pickaxe/mini-projects/depot-app/test/functional/order_notifier_test.rb:17]:
Expected /<td>1&times;<\/td>\s*<td>Programming Ruby 1.9<\/td>/ to match "<h3>Pragmatic Order Shipped</h3>\r\n\r\n<p>\r\n  This is just to let you know we shipped your recent order:\r\n</p>\r\n\r\n<table>\r\n  <tr><th colspan=\"2\">Qty</th><th>Description</th></tr>\r\n  \r\n</table>\r\n".

It was a fixtures problem, but I still havent resolved it. In my line_items.yml file, I have the following:

one:
  product_id: ruby
  cart_id: 1
  order_id: one
</code

That’s where I’m at so far :/

17 Jun 2013, 12:40
Samr_small_pragsmall

Sam Ruby (584 posts)

Try line_items.yml (the comments used by the publishing logic to highlight the line as it appears in the book in section 12.1 are not necessary).

In short: don’t put “_id” when you are referencing another resource by name.

  You must be logged in to comment