Hey Guys, Does Rails set the session[:session_id] field in functional testing? I''ve been getting an empty string... which is causing the url_for function call in my view to blow up. It would be really nice to avoid the following ugly workaround.... <%= if session.session_id != '''' link_to ''Sign Out'', session_url(:id => session.session_id), :method => :delete end %> Sonny. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
You can use @request.session[:session_id] = user.id in the setup method to artificially login in users for the functional tests. On Jul 13, 2:41 pm, Sonny Chee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hey Guys, > > Does Rails set the session[:session_id] field in functional testing? > I''ve been getting an empty string... which is causing the url_for > function call in my view to blow up. It would be really nice to avoid > the following ugly workaround.... > > <%= if session.session_id != '''' > link_to ''Sign Out'', session_url(:id => session.session_id), :method => > :delete end %> > > Sonny. > > -- > Posted viahttp://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?hl=en -~----------~----~----~----~------~----~------~--~---
danlunde wrote:> You can use @request.session[:session_id] = user.id in the setup > method to artificially login in users for the functional tests. > > On Jul 13, 2:41 pm, Sonny Chee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>I''ve tried that but and gotten the following error message: ActionView::TemplateError: session_url failed to generate from {:controller=>"sessions", :id=>"", :action=>"show"}, expected: {:controller=>"sessions", :action=>"show"}, diff: {:id=>""} On line #21 of app/views/layouts/application.rhtml 18: Signed in as <%= link_to user.name, user_url(:id => user)%> 19: <br/> 20: <%= link_to ''Settings'', edit_user_url(:id => current_user)%> 21: <%= link_to ''Sign Out'', session_url(:id => session.session_id), :method => :delete %> ..... -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Maybe line 21 should be session_url(:id => session[:session_id], :method => :delete)) or session_url(:id => current_user, :method => :delete) On Jul 13, 5:53 pm, Sonny Chee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> danlunde wrote: > > You can use @request.session[:session_id] = user.id in the setup > > method to artificially login in users for the functional tests. > > > On Jul 13, 2:41 pm, Sonny Chee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > I''ve tried that but and gotten the following error message: > > ActionView::TemplateError: session_url failed to generate from > {:controller=>"sessions", :id=>"", :action=>"show"}, expected: > {:controller=>"sessions", :action=>"show"}, diff: {:id=>""} > On line #21 of app/views/layouts/application.rhtml > > 18: Signed in as <%= link_to user.name, user_url(:id => user)%> > 19: <br/> > 20: <%= link_to ''Settings'', edit_user_url(:id => current_user)%> > 21: <%= link_to ''Sign Out'', session_url(:id => session.session_id), > :method => :delete %> > > ..... > > -- > Posted viahttp://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?hl=en -~----------~----~----~----~------~----~------~--~---
danlunde wrote:> Maybe line 21 should be > > session_url(:id => session[:session_id], :method => :delete)) > or > session_url(:id => current_user, :method => :delete) > > > On Jul 13, 5:53 pm, Sonny Chee <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thanks for the suggestions, but alas, 1) session[:session_id] is nil in the rendered view 2) :id=>current_user will work... but if someone was malicious they could spam my site with session_url(:id => random_number, :method => :delete) which would result in my users being logged out unexpectedly.... Sonny. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---