Re: functional testing -- using post() w/ a different contro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: functional testing -- using post() w/ a different contro

Zack Chandler
doug wrote:

> Hallo -- I have a function in test_helper.rb that looks not a little
> like this:
>
>   def
> login(username="gowondapiddlehead",unhashed_password="gowonda_piddlehead")
>     post(:login,:system_user=>{:username=>username,:unhashed_password=>unhashed_password})
>     assert_redirected_to(:controller=>'home')
>     assert_not_nil(session[:system_user_id])
>     system_user=SystemUser.find(session[:system_user_id])
>     assert_equal(username,system_user.username,"Login name should match
> session name.")
>   end
>
> When I run the test, however, I get the following error:
>
>     1) Error:
>   test_index(HomeControllerTest):
>   NoMethodError: undefined method `login' for Test::Unit::TestCase:Class
>       test/functional/home_controller_test.rb:18:in `test_index'
>
> I guess this is because I need to specify the controller being called as
> well as the action in the post() function.
> Does anyone know how to do this?
> Cheers,
>    doug.

Doug,
  I'm having the exact same problem.  I have an account controller that
handles the login cycle. In testing another controller that depends on
this cycle I cannot specify the controller, only the action.
  The option to specify another controller should be added.
  Does anyone know a work-around?

Zack


--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|

Re: Re: functional testing -- using post() w/ a different contro

Tom Mornini
On Dec 19, 2005, at 2:22 AM, Zack wrote:

>   I'm having the exact same problem.  I have an account controller  
> that
> handles the login cycle. In testing another controller that depends on
> this cycle I cannot specify the controller, only the action.
>   The option to specify another controller should be added.
>   Does anyone know a work-around?

The functional test operators take a session argument, where you can set
the session up. Just test the pages by setting the session that  
indicates
a login...

     get :show,             # <- method
         {  },              # <- params
         { :user_id => 4 }  # <- session

--
-- Tom Mornini

_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails