Ruby.Me.Silly
2007-Jan-12 19:00 UTC
assert_redirected_to Exception occurs with RESTful application
Let me start off by stating something really funky is going on with posting messages to this group. This is not the first time I''ve posted a message only to find it never appears in the group listing. Does anyone else have this problem or does someone have it out for me? :) I am receiving an exception on execution of a functional test. The exception messages reads as: "NoMethodError: undefined method `first'' for :users:Symbol" -------------------------- My routes.rb contains the entry: map.resources :users --------------------------- My users_controller.rb contains the following in the action I am testing: def create @user= Task.new(params[:task]) @user.save flash[:notice] = "Task was successfully created" redirect_to user_url(@user) end --------------------------- My users_controller_test.rb contains this test: def test_create_user User.delete_all post :create, { :user => { :username => "john", :password => "rubycon", :first_name => "John", :last_name => "Smith" } } assert_equal "Task was successfully created", flash[:notice] assert_redirected_to :controller => :tasks end ---------------------------- I know the logic is thin but I''m keeping it that way to resolve the issue. The exception is occuring on the assert_redirected_to line in the functional test. I would appreciate any feedback on this problem. I''ve not had any luck determining a fix from Google or discussion group searches. Thanks! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Russell Norris
2007-Jan-13 13:40 UTC
Re: assert_redirected_to Exception occurs with RESTful application
If you''re mapping the TaskController via map.resources :tasks, you might try assert_redirected_to named_task_route. I know I''ve run across this problem before but I really can''t remember what I did to go around it. [shrugs] RSL On 1/12/07, Ruby.Me.Silly <RubyMeSilly-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Let me start off by stating something really funky is going on with > posting messages to this group. This is not the first time I''ve posted > a message only to find it never appears in the group listing. Does > anyone else have this problem or does someone have it out for me? :) > > I am receiving an exception on execution of a functional test. The > exception messages reads as: > "NoMethodError: undefined method `first'' for :users:Symbol" > > -------------------------- > My routes.rb contains the entry: > > map.resources :users > --------------------------- > My users_controller.rb contains the following in the action I am > testing: > > def create > @user= Task.new(params[:task]) > @user.save > flash[:notice] = "Task was successfully created" > redirect_to user_url(@user) > end > --------------------------- > My users_controller_test.rb contains this test: > > def test_create_user > User.delete_all > > post :create, > { :user => { > :username => "john", > :password => "rubycon", > :first_name => "John", > :last_name => "Smith" } } > > assert_equal "Task was successfully created", flash[:notice] > assert_redirected_to :controller => :tasks > end > ---------------------------- > > I know the logic is thin but I''m keeping it that way to resolve the > issue. The exception is occuring on the assert_redirected_to line in > the functional test. > > I would appreciate any feedback on this problem. I''ve not had any luck > determining a fix from Google or discussion group searches. > > Thanks! > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---