Fix up the default body thing

This commit is contained in:
Jacques Crocker 2010-08-01 00:50:29 -07:00
parent 925c7fff8d
commit d872805101
3 changed files with 5 additions and 2 deletions

View File

@ -8,7 +8,7 @@ module Models
included do
before_validation do |p|
if p.parts.empty?
p.parts << PagePart.build_body_part(p.try(:body))
p.parts << PagePart.build_body_part(p.respond_to?(:body) ? p.body : nil)
end
end
end

View File

@ -15,6 +15,9 @@ class Page
field :published, :type => Boolean, :default => false
field :cache_strategy, :default => 'none'
# allows newly pages to have a default body
attr_accessor :body
## associations ##
referenced_in :site
referenced_in :layout

View File

@ -354,7 +354,7 @@ describe Page do
end
it "should render the passed in body attribute of the page" do
@page.render(Liquid::Context.new).should == "PageBody"
@page.render(Liquid::Context.new).should == "Page Body"
end
end
end