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
on 31.03.2006 20:37
on 31.03.2006 20:49
> 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
on 31.03.2006 23:10
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
on 01.04.2006 03:08
I filed ticket 4400 regarding this... and then I rewrote my tests. :)
on 03.04.2006 02:30
I got bitten by this as well. I think it should be mentioned in the release notes. Kent.