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?
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.