From bf14f3522367f1543c9f3a85065a9c51929b3281 Mon Sep 17 00:00:00 2001 From: Gregor Schmidt Date: Mon, 25 Jul 2011 16:06:29 +0200 Subject: [PATCH] [#537] version of new WikiContents should be 0 --- app/models/wiki_content.rb | 7 +------ test/unit/wiki_content_test.rb | 7 +++++++ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index 660a84a7..9533a8a7 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -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 diff --git a/test/unit/wiki_content_test.rb b/test/unit/wiki_content_test.rb index 39c48747..0cdf2718 100644 --- a/test/unit/wiki_content_test.rb +++ b/test/unit/wiki_content_test.rb @@ -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