Hi all. I''m using the ApplicationController to set a session variable for all other controllers. It works. However, when performing functional tests, it appears that calling a controller doesn''t invoke its parent''s before_filter method. I''ve tried, in my tests, calling ApplicationController''s methods directly, but I either get weird errors (e.g. "using a symbol as an array index session[:cart]") or the variable assignments (session, instance, whatever) don''t propagate to children controllers. I can test my actual ApplicationController for correctness, but unless I tell it to render(:nothing => true) (a big no-no if you use your imagination) or put in an actual view for it to render I get an error during testing saying it couldn''t render anything. I''d rather not have random views (okay, 1 random view, but still) floating around just to get a test to work. Has anyone gotten around this? Thanks, much! -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
It also seems, at least in the testing environment, that a controller outside the one being tested does not have access to the session method. A exception is raised stating I''m attempting to issue [] on nil. The only occurences of [] are attached to session. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Hi guys I have sort of the same problem: I get a "Symbol as array index" error when trying to read a session value such as session[:user_id] The only solution I could find by googling around is to append @request to session: @request.session[:user_id] - However this just gives an error saying that the @request object wasn''t initialised and so the call is interpreted as nil.session Can anyone help? Patrick --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Patrick wrote:> session: @request.session[:user_id] > > - However this just gives an error saying that the @request object > wasn''t > initialised and so the call is interpreted as nil.sessionHave you got [code] def setup @controller = <controller_name>Controller.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end [/code] in your functional test? it should be *generated* by rails. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---