When I test functionals, I get the following error:
<pre><code>test_should_display_index(AlertsControllerTest):
ActionView::TemplateError: undefined method `name' for nil:NilClass
On line #9 of app/views/alerts/index.html.erb
6:
7: <tr class="<%= row_class %>">
8: <td scope="row" class="first
odd"><%=h alert.title %></td>
9: <td class="even"><%=h
alert.file_status.name %></td>
10: <td class="last odd"><%= render
:partial => "shared/action_links", :locals => { :obj
=> alert, :type => "alert" } %>
11: </td>
12: </tr>
</code></pre>
This test should confirm the proper display of the index for class
Alerts. Alerts belong to class FileStatuses. Each file_status contains
two objects: :id and :name.
<code><%=h alert.file_status.name %></code> produces the expected
result when viewed in a browser (either `draft`, `published` or `trash`
depending on the individual alert's setting). So it seems that the
only thing finding this error is the test.
The test is pretty straight forward. Its code is:
<pre><code>class AlertsControllerTest < ActionController::TestCase
test "should display index" do
get :index
assert_response :success
assert_template 'index'
assert_not_nil assigns(@alert)
end
end</code></pre>
So what am I doing wrong?