Error of Testing index (undefined)

Hi,

I follow the tutorial of testing the params then i got the error when
i test..
can someone help me

Thanks for your help

Yennie

code
def disable
    if !(@user = User.find_by_id(params[:id]))
      render :action => "common/error_notfound"
    else
      @user.save
      @users = User.find(:all)
      redirect_to( {:action=>"index"}
    end
  end

test
    it "should not go to index" do
        get :index, :user => {:email => "testing",
          :password => "12345",
          :name => "you"}
  assigns[:user].name.should == "you"
  response.should redirect_to('index')
    end

error
       undefined method `name' for nil:NilClass

Yennie wrote in post #1011712:

Hi,

I follow the tutorial of testing the params then i got the error when
i test..
can someone help me

Thanks for your help

Yennie

code
def disable
    if !(@user = User.find_by_id(params[:id]))
      render :action => "common/error_notfound"
    else
      @user.save
      @users = User.find(:all)
      redirect_to( {:action=>"index"}
    end
  end

test
    it "should not go to index" do
        get :index, :user => {:email => "testing",
          :password => "12345",
          :name => "you"}
  assigns[:user].name.should == "you"
  response.should redirect_to('index')
    end

error
       undefined method `name' for nil:NilClass

If you're trying to test the disable action/method then why are you
getting index (get :index, :user => ...)?

And, besides that your disable action is probably not safe nor
idempotent so you should not be sending a GET request to it. You should
use PUT (or at least POST).

put :disable, :user => ....

Also make sure you have a valid route defined for the disable action on
that controller.

Robert Walker wrote in post #1012664:

And, besides that your disable action is probably not safe nor
idempotent so you should not be sending a GET request to it. You should
use PUT (or at least POST).

For an explanation of this see:

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html