Hello, I''m trying to write some functionnal tests for one of my controllers and I''ve got a strange problem. In my test code I''m doing the following : def test_index_user_not_login get :index assert_response :redirect assert_redirected_to :controller => "user", :action => "login" end and when I launch the test, I''ve got this error : 1) Failure: test_index_user_not_login(Admin::ConfigurationControllerTest) [./test/ functional/admin/configuration_controller_test.rb:20]: response is not a redirection to all of the options supplied (redirection is <{:action=>"login", :controller=>"user"}>), difference: <{}> So if I understand, the testing tasks tells me that my redirection isn''t correct (I test it by hand and it works well) and that''s the difference is {}, so nothing different ... Odd. If I change: assert_redirected_to :controller => "user", :action => "login" to: assert_redirected_to :action => "login" it works ... Any clue ? -- Nicolas Cavigneaux http://www.bounga.org http://www.cavigneaux.net --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
What is the actual redirect_to call? I''ve found that Rails can be quite picky with functional tests and redirect checking, so make sure that the url_options are the exact same in both places. Jason On 8/25/06, Nicolas Cavigneaux <nico-DRabjd/C3MEdnm+yROfE0A@public.gmane.org> wrote:> > > Hello, > > I''m trying to write some functionnal tests for one of my controllers > and I''ve got a strange problem. In my test code I''m doing the > following : > > def test_index_user_not_login > get :index > assert_response :redirect > assert_redirected_to :controller => "user", :action => "login" > end > > and when I launch the test, I''ve got this error : > > 1) Failure: > test_index_user_not_login(Admin::ConfigurationControllerTest) [./test/ > functional/admin/configuration_controller_test.rb:20]: > response is not a redirection to all of the options supplied > (redirection is <{:action=>"login", :controller=>"user"}>), > difference: <{}> > > So if I understand, the testing tasks tells me that my redirection > isn''t correct (I test it by hand and it works well) and that''s the > difference is {}, so nothing different ... Odd. > > If I change: > > assert_redirected_to :controller => "user", :action => "login" > > to: > > assert_redirected_to :action => "login" > > it works ... > > Any clue ? > -- > Nicolas Cavigneaux > http://www.bounga.org > http://www.cavigneaux.net > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Le 25 août 06 à 22:40, Jason Roelofs a écrit :> What is the actual redirect_to call? I''ve found that Rails can be > quite picky with functional tests and redirect checking, so make > sure that the url_options are the exact same in both places.The redirect_to is : redirect_to :controller => ''user'', :action => ''login'' It''s the one found in authenticated_system.rb that''s ship with Acts_as_authenticated ... I''m using a before_filter with the login_required method to ensure that the user is login to access an admin page. -- Nicolas Cavigneaux http://www.bounga.org http://www.cavigneaux.net --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
i has this exact problem and my redirect_to did NOT have the :controller part. Are you sure yours does? in my Post controller i can call redirect_to :action => ''list'' if I then test for the following it will fail. assert_redirected_to :controller => ''post'', :action => "list" Double check that your not doing this. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Le 26 août 06 à 01:40, jdonnell a écrit :> > i has this exact problem and my redirect_to did NOT have the > :controller part. Are you sure yours does?Mine does yes. I''m pretty sure it''s a Rails bug because if I do this: assert_redirected_to @controller.url_for(:controller => ''user'', :action => ''login'') it works like a charm ... So I''m wondering why assert_redirected_to :controller => ''user'', :action => ''login'' doesn''t work ... I''m going to check if there''s a bug report for that and if it doesn''t I''m going to open one. -- Nicolas Cavigneaux http://www.bounga.org http://www.cavigneaux.net --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---