Mercurial > hg > soundsoftware-site
diff test/unit/wiki_page_test.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbce1fd3b1b7 |
children | 622f24f53b42 |
line wrap: on
line diff
--- a/test/unit/wiki_page_test.rb Wed Jun 27 14:54:18 2012 +0100 +++ b/test/unit/wiki_page_test.rb Mon Jan 07 12:01:42 2013 +0000 @@ -1,5 +1,5 @@ # Redmine - project management software -# Copyright (C) 2006-2011 Jean-Philippe Lang +# Copyright (C) 2006-2012 Jean-Philippe Lang # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -85,16 +85,18 @@ # A page that doesn't exist page.parent_title = 'Unknown title' assert !page.save - assert_equal I18n.translate('activerecord.errors.messages.invalid'), page.errors.on(:parent_title) + assert_include I18n.translate('activerecord.errors.messages.invalid'), + page.errors[:parent_title] # A child page page.parent_title = 'Page_with_an_inline_image' assert !page.save - assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title) + assert_include I18n.translate('activerecord.errors.messages.circular_dependency'), + page.errors[:parent_title] # The page itself page.parent_title = 'CookBook_documentation' assert !page.save - assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title) - + assert_include I18n.translate('activerecord.errors.messages.circular_dependency'), + page.errors[:parent_title] page.parent_title = 'Another_page' assert page.save end @@ -123,9 +125,39 @@ end def test_updated_on_eager_load - page = WikiPage.with_updated_on.first + page = WikiPage.with_updated_on.first(:order => 'id') assert page.is_a?(WikiPage) assert_not_nil page.read_attribute(:updated_on) + assert_equal Time.gm(2007, 3, 6, 23, 10, 51), page.content.updated_on assert_equal page.content.updated_on, page.updated_on + assert_not_nil page.read_attribute(:version) + end + + def test_descendants + page = WikiPage.create!(:wiki => @wiki, :title => 'Parent') + child1 = WikiPage.create!(:wiki => @wiki, :title => 'Child1', :parent => page) + child11 = WikiPage.create!(:wiki => @wiki, :title => 'Child11', :parent => child1) + child111 = WikiPage.create!(:wiki => @wiki, :title => 'Child111', :parent => child11) + child2 = WikiPage.create!(:wiki => @wiki, :title => 'Child2', :parent => page) + + assert_equal %w(Child1 Child11 Child111 Child2), page.descendants.map(&:title).sort + assert_equal %w(Child1 Child11 Child111 Child2), page.descendants(nil).map(&:title).sort + assert_equal %w(Child1 Child11 Child2), page.descendants(2).map(&:title).sort + assert_equal %w(Child1 Child2), page.descendants(1).map(&:title).sort + + assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants.map(&:title).sort + assert_equal %w(Child1 Child11 Child111 Child2 Parent), page.self_and_descendants(nil).map(&:title).sort + assert_equal %w(Child1 Child11 Child2 Parent), page.self_and_descendants(2).map(&:title).sort + assert_equal %w(Child1 Child2 Parent), page.self_and_descendants(1).map(&:title).sort + end + + def test_diff_for_page_with_deleted_version_should_pick_the_previous_available_version + WikiContent::Version.find_by_page_id_and_version(1, 2).destroy + + page = WikiPage.find(1) + diff = page.diff(3) + assert_not_nil diff + assert_equal 3, diff.content_to.version + assert_equal 1, diff.content_from.version end end