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 2006-03-31 20:37
on 2006-03-31 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 2006-03-31 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