Handle deleted wiki page versions (#10852).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10684 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang committed 2012-10-21 04:43:15 +00:00
1 parent f09be68323
commit 9796d18609
5 files changed
+68 -11

No files matched your search

+38
View File
@@ -122,4 +122,42 @@ class WikiContentTest < ActiveSupport::TestCase
assert_equal true, content.versions.first(:order => 'version DESC').current_version?
assert_equal false, content.versions.first(:order => 'version ASC').current_version?
end
def test_previous_for_first_version_should_return_nil
content = WikiContent::Version.find_by_page_id_and_version(1, 1)
assert_nil content.previous
end
def test_previous_for_version_should_return_previous_version
content = WikiContent::Version.find_by_page_id_and_version(1, 3)
assert_not_nil content.previous
assert_equal 2, content.previous.version
end
def test_previous_for_version_with_gap_should_return_previous_available_version
WikiContent::Version.find_by_page_id_and_version(1, 2).destroy
content = WikiContent::Version.find_by_page_id_and_version(1, 3)
assert_not_nil content.previous
assert_equal 1, content.previous.version
end
def test_next_for_last_version_should_return_nil
content = WikiContent::Version.find_by_page_id_and_version(1, 3)
assert_nil content.next
end
def test_next_for_version_should_return_next_version
content = WikiContent::Version.find_by_page_id_and_version(1, 1)
assert_not_nil content.next
assert_equal 2, content.next.version
end
def test_next_for_version_with_gap_should_return_next_available_version
WikiContent::Version.find_by_page_id_and_version(1, 2).destroy
content = WikiContent::Version.find_by_page_id_and_version(1, 1)
assert_not_nil content.next
assert_equal 3, content.next.version
end
end