Hi - I''m trying to use Rails integration tests to test across controllers/actions. Unfortunately, the integration tests break other (unit) tests because the integration tests leave around data in the session. We can tell this because the tests that fail involve asserts on redirects that should happen when the session is empty (i.e., when the user is not logged in). Here''s what I''m doing: def test_pagination s = open_session do |s| login_as(users(:sarah)) # rest of the test here... end s.reset! end Additionally, I''ve tried other ways of resetting the session, including skipping the open_session block and just calling reset! in teardown, as well as ''get "/user/logout"'' to force the session to be reset through the app. The api documentation as well as the Rails Recipe book suggest that this should work. Am I missing something simple or does someone have some insight to this problem? Thanks! pt -- Parker Thompson http://www.parkert.com/ 510.541.0125 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Perhaps I''m missing something but I don''t see why this doesn''t work. Using ''open_session'' should create a new session instance enabling us to mimic multiple users hitting the server. Each session instance should be seperate; isolated from the others. Is it possible you''re inadvertantly setting an application-level session variable and asserting based on that value? Parker Thompson wrote:> Hi - > > I''m trying to use Rails integration tests to test across > controllers/actions. Unfortunately, the integration tests break other > (unit) tests because the integration tests leave around data in the > session. We can tell this because the tests that fail involve asserts > on redirects that should happen when the session is empty (i.e., when > the user is not logged in). Here''s what I''m doing: > > def test_pagination > s = open_session do |s| > login_as(users(:sarah)) > # rest of the test here... > end > s.reset! > end > > Additionally, I''ve tried other ways of resetting the session, > including skipping the open_session block and just calling reset! in > teardown, as well as ''get "/user/logout"'' to force the session to be > reset through the app. > > The api documentation as well as the Rails Recipe book suggest that > this should work. Am I missing something simple or does someone have > some insight to this problem? Thanks! > > > pt > > > -- > Parker Thompson > http://www.parkert.com/ > 510.541.0125--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---