On Apr 29, 2010, at 12:27 PM, Joachim wrote:

On 04/29/2010 04:30 PM, Chris Apolzon wrote:
Just a shot in the dark, but a 302 is a redirect, so even though it
*appears* to work when you do a manual check you might just be missing
the fact that you were redirected.

Unluckily for me thats not the case

Failure is

---
 1) Failure:
test_logged_in_can_access(FriendsControllerTest)
[/test/functional/friends_controller_test.rb:23]:
Expected response to be a <:success>, but was <302>
---

and test is

---
 def test_logged_in_can_access
   log_in('Abraham', 'pass')
   get :index
   assert_response :redirect
   assert_redirected_to :controller => :users, :action => :login
   assert_response :success
 end
---

so assertions
   assert_response :redirect
   assert_redirected_to :controller => :users, :action => :login
succeed and
   assert_response :success
fails. Which means I'm redirected to login page ( in this test).

I suspect I'm doing login or fixture wrong:

---
   def log_in(uname, pass)
     post :controller => :users, :action => :login, :login => uname,
:password => pass
   end
---

Doing two requests in a functional test has (in the past) really confused Rails. I'm not sure if that's still the case. You *should* be able to effectively simulate a login by setting the appropriate session variable, but there was just a thread about how *that* wasn't working either. I'll try to tear into this this weekend; I *know* it works, as I've got a couple production apps with functional tests...

--Matt Jones

--
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to