Rails controller tests: "Filter chain halted" never appears

41 Views Asked by At

In development, my Rails log shows Filter chain halted when some before_action filter is unsatisfied, but when I run controller tests in rspec, I don't get any such information in the log.

Setting up controller tests can be a slow process in the application on which I'm working because there is an enormous legacy of before_action filters and a lack of test coverage. Usually, some of these filters are unsatisified when I start to write new controller tests, and I'd like to easily see which ones by checking my log/test.log, but it gives no insight, even when Rails.logger.level is :debug.

Is there a way for me to get this information in the log or in the controller test?

1

There are 1 best solutions below

3
kwerle On

Maybe your ancient app is skipping before_actions in test to speed them up?

The two steps I would take:

  • write request tests instead of controller tests
  • consider adding a prepend_before_action that fires up the debugger and step through to see what's getting called

The second one is where you're really going to learn something. If it doesn't get called then something has been shorted out. If it does get called then you should be able to step up and through the rest of the callbacks and see what's going on.