I'm curious about the performed? method in ActionController::Base.
It's not documented, but I've found it useful in a specific testing
scenario that I'll describe below. How is it intended to be used (or
is it)? Is there a more Railsy way of doing what I'm using it for?
I'm currently in the process of refactoring a large "legacy" Rails app
(isn't it exciting that these now exist? It was originally something
like rails 0.13) that had almost zero test coverage. There are some
kitchen sink methods in ApplicationController that perform redirects
in certain failure scenarios. From what I can tell, it looks like the
controllers that call this method rely on their default view rendering
behavior to avoid DoubleRenderErrors. Before I can refactor such
behavior out, I need to add test coverage to be sure I don't cause
unintended side effects.
I'm using rspec and have the following inside
describe ApplicationController do
class TestController < ApplicationController
redirect_to '/home/index' unless performed?
Without the performed? check, I get less helpful failures
(DoubleRenderError instead of what is actually triggering the extra
render in method_under_test). Oh, and the redirect_to '/home/index'
part is so that I don't get failures for nonexistent view templates
via a default render call.