I am writing a small CMS as a Rails test project (I also plan to use it for my personal site). I want SEO-friendly URLs, so I have a test to check that permalinks are automatically generated based on the page title (e.g. About Us => about-us). However, I cannot understand why this test fails. Here is the code (I am using Rails 2.3.2):
# page_test.rb
What happens is that the permalink is zero, not the example page, as it should be. It works, however, if I manually put a permalink in the device and change the test around, for example:
p - pages(:sample_page) p.title = "Contact Us" p.save assert_equal "contact-us", p.permalink
I could fix this, but I wonder why it does not run the before_save method for the original test.
source share