Removing wildcard routes

Target: remove the :controller/:action(/:id) routes from config/routes.rb.

Problem: make sure we have complete route coverage.

Well, the problem can be solved in two ways:

  • Go into every controller and translate each action to a routing spec.
  • Parse last week’s logs and check whether each url is routable.

The first solution sounds easy but the second one sounds more fun. :-)

Recipe

Remove the wildcard routes from config/routes.rb

The offending lines look something like this:

match ':controller(/:action(/:id(.:format)))'

Get rid of them.

Get a few days’ worth of haproxy.log (or some other log)

Just ask your admin for that.

Take a random sample out of it:

Usually

cat ~/Logs/haproxy.log | shuf -n 1000 >> test/fixtures/logs/requests.log

will suffice.

Translate each url into a routing spec

Use the following sample spec file and edit it to skip known failing urls and fix subdomains.