[#537] version of new WikiContents should be 0

This commit is contained in:
Gregor Schmidt 2011-07-25 16:06:29 +02:00 committed by Holger Just
parent a35d61bfb7
commit bf14f35223
2 changed files with 8 additions and 6 deletions

View File

@ -59,12 +59,7 @@ class WikiContent < ActiveRecord::Base
end
def version
unless last_journal
# FIXME: This is code that caters for a case that should never happen in the normal code paths!!
create_journal
last_journal.update_attribute(:created_at, updated_on)
end
last_journal.version
new_record? ? 0 : last_journal.version
end
private

View File

@ -80,4 +80,11 @@ class WikiContentTest < ActiveSupport::TestCase
page.reload
assert_equal 500.kilobyte, page.content.text.size
end
test "new WikiContent is version 0" do
page = WikiPage.new(:wiki => @wiki, :title => "Page")
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
assert_equal 0, page.content.version
end
end