Gian
2007-Jun-25 11:44 UTC
Functional tests and active scaffold: unexpected assertion failure.
Hello, I''m writing a functional test for a controller that uses active scaffold. def test_presence_of_field login_as(:peter) profile = Profile.find :first get :edit, {:id => profile.id} assert_response 200 assert_select "textarea#record_free_text_ec" end I was expecting the first ''assert 200'' to give me a green bar, but added it for confirmation, and indeed it gives me te following failure: Expected response to be a <200>, but was <0> The same assertion works fine when I don''t use active scaffold. Does anyone know how to solve this problem? Cheers, Gian --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Gian
2007-Jun-26 11:06 UTC
Re: Functional tests and active scaffold: unexpected assertion failure.
Just for the records, for whoever might end up on this thread. I found out what the problem was, it has nothing to do with active scaffold. The cause of this problem was a missing fixture in my tests. More specifically. I use the plug in act_as_authenticated, and the first line in my tests is usually login_as(:peter), that sets the user as logged in. The method login_as worked fine, and the @current_user instance variable was set in my controllers, but the instances of an association (i.e. has_and_belongs_to_many :roles) where not made and not set in the specific user instance, this caused some conditions to fail and resulted in a redirect. Moral of the story: I needed to add an extra fixture to my functional test. On 25 jun, 13:44, Gian <gian.franco.cas...-aZ+A4iwyWieEVqv0pETR8A@public.gmane.org> wrote:> Hello, > > I''m writing a functional test for a controller that usesactivescaffold. > > def test_presence_of_field > login_as(:peter) > profile = Profile.find :first > get :edit, {:id => profile.id} > assert_response 200 > assert_select "textarea#record_free_text_ec" > end > > I was expecting the first ''assert 200'' to give me a green bar, > but added it for confirmation, and indeed it gives me te > following failure: > Expected response to be a <200>, but was <0> > > The same assertion works fine when I don''t useactivescaffold. > > Does anyone know how to solve this problem? > > Cheers, > > Gian--~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---