Assert_redirected_to Exception occurs with RESTful applicati

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? :slight_smile:

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!

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