Hi All,
So I worked out how to have my logged in session data persist across
functional tests:
login_admin
post :users, nil, {:user_id => session[:user_id]}
assuming that our login_admin operation succeeds I can maintain that
session data in the subsequent post.
However, I am now confronted with the problem that while the controller
can see this session data, some of the partials in the associated layout
don''t seem to be able to see the session, i.e. I get an error like
this:
-----------------------
ActionView::TemplateError: WARNING: You have a nil object when you
probably didn''t expect it! Odds are you want an instance of Array
instead.
Look in the callstack to see where you''re working with an object that
could be nil.
Investigate your methods and make sure the object is what you expect!
On line #6 of /layouts/_logout.rhtml
3: <tr>
4: <td nowrap>
5: logged in as<br>
6: <%= User.find(session[:user_id]).full_name %>
7: </td>
8: </tr>
9: <tr>
----------------------------
The partial _logout.rhtml is pulled in as part of the layout my
controller uses, and while all this works fine in a browser on devel,
running in test mode I am kind of stuck. Is there something I can do
ensure that the session passed in by a test post will be available
through all parts of the layout ...?
Many thanks in advance.
CHEERS> SAM