I have several ‘admin’ controllers, all of which inherit from AdminController, which has a before filter that restricts access to admins only.
I want my functional tests to check that only admins can access every action of every controller that is part of my admin system. What is the most succinct way to do this?
(I’m using the standard built-in test/unit)
I think the most succinct way would be through metaprogramming:
You’ll have to handle gets vs. posts, and there’s probably some typos, but hopefully that gives you something to start. (Also, this is using the minispec syntax. You’ll have to translate a bit for test/unit.)
I’d probably recommend just adding the simple tests on a controller-by-controller basis, but this is probably a good integration test just to make sure you don’t miss any.