|
Table of Contents
|
One of the large changes in Rails 1.2 is a re-worked routing system. After the upgrade to Rails 1.2, one of the things that should be re-considered are routes. This means we should 1) move to use named routes, 2) the *RoutesTests should be rewritten in the correct format and 3) the ThemingSystem can refine how it makes its routes.
Use named routes
Rails 1.2 introduces the concept of named routes, which are often a superior alternative to the unnamed routes of Rails 1.1. Furthermore, there is a difference between explicit and implicit routes, where the use of explicit routes is prefered. Therefore, we'll switch to using explicit named routes in Chameleon 0.6.2, which will be easier to manage for upcoming versions.
For more information on the difference between named/unnamed and explicit/implicit routes, and reasons why to use explicit named routes, see http://weblog.jamisbuck.org/2007/1/22/named-explicit-routes.
Rewrite *RoutesTests
After or simultaneously when the routes are rewritten, the tests for the routes should be rewritten too. This is not only because we're changing the format in which we write the routes, but also because there is a more effective way to write the routes. Currently, the tests to check the routes in RoutesTest and AdminRoutesTest use a format like this one:
# Homepage
assert_equal "/", url_for(:controller => "blog", :action => "home", :only_path => true)
assert_equal "/", url_for(:controller => "blog", :only_path => true)
# / should render the homepage
get "/"
assert_template "blog/home"
However, there are assert_* functions made espacially for checking routes, as described at http://manuals.rubyonrails.com/read/chapter/28#page236. It would probably be better using this functions. The example above would become:
# Homepage
assert_routing "/", {:controller => "blog", :action => "home"}
assert_generates "/", {:controller => "blog"}
Refine the routes made by the ThemingSystem
TODO





