Forum: Ruby on Rails Functional tests and active scaffold: unexpected assertion f

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F146b6a268a7021e4a55286b34abe32e?d=identicon&s=25 Gian (Guest)
on 2007-06-25 13:44
(Received via mailing list)

I'm writing a functional test for a controller that uses active

def test_presence_of_field
  profile = Profile.find :first
  get :edit, {:id =>}
  assert_response 200
  assert_select "textarea#record_free_text_ec"

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?


F146b6a268a7021e4a55286b34abe32e?d=identicon&s=25 Gian (Guest)
on 2007-06-26 13:07
(Received via mailing list)
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

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
(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
This topic is locked and can not be replied to.