diff --git a/lib/jekyll/convertible.rb b/lib/jekyll/convertible.rb index f0348ab5..23783691 100644 --- a/lib/jekyll/convertible.rb +++ b/lib/jekyll/convertible.rb @@ -3,6 +3,10 @@ # # Requires # self.site -> Jekyll::Site +# self.content= +# self.data= +# self.ext= +# self.output= module Jekyll module Convertible # Return the contents as a string diff --git a/lib/jekyll/post.rb b/lib/jekyll/post.rb index 914cfd59..55d4d1e3 100644 --- a/lib/jekyll/post.rb +++ b/lib/jekyll/post.rb @@ -18,12 +18,9 @@ module Jekyll name =~ MATCHER end - attr_accessor :site, :date, :slug, :ext, :published, :data, :content, :output, :tags - attr_writer :categories - - def categories - @categories ||= [] - end + attr_accessor :site + attr_accessor :data, :content, :output, :ext + attr_accessor :date, :slug, :published, :tags, :categories # Initialize this Post instance. # +site+ is the Site @@ -51,9 +48,8 @@ module Jekyll self.tags = [self.data["tag"]] elsif self.data.has_key?("tags") self.tags = self.data['tags'] - else - self.tags = [] end + self.tags ||= [] if self.categories.empty? if self.data.has_key?('category') @@ -68,6 +64,7 @@ module Jekyll end end end + self.categories ||= [] end # Spaceship is based on Post#date, slug diff --git a/test/test_post.rb b/test/test_post.rb index 649e2f46..78b86730 100644 --- a/test/test_post.rb +++ b/test/test_post.rb @@ -36,6 +36,7 @@ class TestPost < Test::Unit::TestCase end should "keep date, title, and markup type" do + @post.categories = [] @post.process(@fake_file) assert_equal Time.parse("2008-10-19"), @post.date @@ -202,6 +203,13 @@ class TestPost < Test::Unit::TestCase end context "initializing posts" do + + should "ensure suitable defaults for attributes" do + post = setup_post("2009-06-22-no-yaml.textile") + assert_equal [], post.tags + assert_equal [], post.categories + end + should "publish when published yaml is no specified" do post = setup_post("2008-02-02-published.textile") assert_equal true, post.published