Ruby Forum Rails-core (closed, excessive spam) > Flash problem with upgrade to Rails 1.1?

Posted by John W. Long (Guest)
on 31.03.2006 20:37
(Received via mailing list)
While upgrading to Rails 1.1 one of my tests started failing which
wasn't failing before:

   def test_developer_action__not_allowed_if_other
     @developer_actions.each do |action|
       get action, { :id => 1 }, { :user => users(:existing) }, {}
       assert_redirected_to page_index_url, "action: #{action}"
       assert_match /privileges/, flash[:error], "action: #{action}"
     end
   end

@developer_actions is an array of action names to test. The test made it
through the first loop, but failed on the second. The reason it failed
was because the flash wasn't being set on the second loop. Instead the
flash was empty. Totally empty.

The problem goes away for me if I simply add a call to setup before the
call to get:

   def test_developer_action__not_allowed_if_other
     @developer_actions.each do |action|
>>>   setup
       get action, { :id => 1 }, { :user => users(:existing) }, {}
       assert_redirected_to page_index_url, "action: #{action}"
       assert_match /privileges/, flash[:error], "action: #{action}"
     end
   end

Setup of course creates a new controller, request, etc... Has something
changed in the upgrade to 1.1 that would effect multiple process calls
in a controller test?

--
John Long
http://wiseheartdesign.com
Posted by Rick Olson (Guest)
on 31.03.2006 20:49
(Received via mailing list)
> Setup of course creates a new controller, request, etc... Has something
> changed in the upgrade to 1.1 that would effect multiple process calls
> in a controller test?
>
> --
> John Long
> http://wiseheartdesign.com

New controller instances are created on each request anyway.  I try
not to do multiple controller requests in a single test case for this
reason.  Anything requiring multiple requests can go into integration
tests.

--
Rick Olson
http://techno-weenie.net
Posted by John W. Long (Guest)
on 31.03.2006 23:10
(Received via mailing list)
Rick Olson wrote:
>> Setup of course creates a new controller, request, etc... Has something
>> changed in the upgrade to 1.1 that would effect multiple process calls
>> in a controller test?
> 
> New controller instances are created on each request anyway.  I try
> not to do multiple controller requests in a single test case for this
> reason.  Anything requiring multiple requests can go into integration
> tests.

Ok. That's a good point. I certainly don't mind rewriting my code.

I brought this up because I thought it might indicate a bug in
test_process.rb. It seems like it's handling the flash in a different 
way.

--
John Long
http://wiseheartdesign.com
Posted by Benjamin Curtis (Guest)
on 01.04.2006 03:08
(Received via mailing list)
I filed ticket 4400 regarding this... and then I rewrote my tests. :)
Posted by Kent Sibilev (Guest)
on 03.04.2006 02:30
(Received via mailing list)
I got bitten by this as well. I think it should be mentioned in the 
release
notes.

Kent.