diff --git a/lib/autoblog/post.rb b/lib/autoblog/post.rb index 4b494abf..80eefff9 100644 --- a/lib/autoblog/post.rb +++ b/lib/autoblog/post.rb @@ -22,6 +22,10 @@ module AutoBlog self.slug = slug self.ext = ext end + + def url + self.date.strftime("/%Y/%m/%d/") + self.slug + end end end \ No newline at end of file diff --git a/test/test_post.rb b/test/test_post.rb index 7fdd24a0..7649e1e2 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -10,7 +10,7 @@ class TestPost < Test::Unit::TestCase assert !Post.valid?("blah") end - def test_site_init + def test_process p = Post.allocate p.process("2008-10-19-foo-bar.textile") @@ -18,4 +18,11 @@ class TestPost < Test::Unit::TestCase assert_equal "foo-bar", p.slug assert_equal "textile", p.ext end + + def test_url + p = Post.allocate + p.process("2008-10-19-foo-bar.textile") + + assert_equal "/2008/10/19/foo-bar", p.url + end end \ No newline at end of file