More tests
OK, at least now we have some BASIC test coverage.
This commit is contained in:
parent
305b37b401
commit
bd77c75403
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
# encoding: UTF-8
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../../test_helper'
|
require File.dirname(__FILE__) + '/../../test_helper'
|
||||||
require 'chunks/wiki'
|
require 'chunks/wiki'
|
||||||
|
@ -79,6 +80,13 @@ class WikiTest < Test::Unit::TestCase
|
||||||
assert_equal %w(pagename WikiWord x), recognized_includes
|
assert_equal %w(pagename WikiWord x), recognized_includes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_redirects_chunk_pattern
|
||||||
|
content = 'This is a [[!redirects pagename]] and [[!redirects WikiWord]] and' +
|
||||||
|
' [[!redirects x]] and [[!redirects page name]] but [[blah]]'
|
||||||
|
recognized_redirects = content.scan(Redirect.pattern).collect { |m| m[0] }
|
||||||
|
assert_equal %w(pagename WikiWord x page\ name), recognized_redirects
|
||||||
|
end
|
||||||
|
|
||||||
def test_textile_link
|
def test_textile_link
|
||||||
textile_link = ContentStub.new('"Here is a special link":SpecialLink')
|
textile_link = ContentStub.new('"Here is a special link":SpecialLink')
|
||||||
WikiChunk::Word.apply_to(textile_link)
|
WikiChunk::Word.apply_to(textile_link)
|
||||||
|
|
|
@ -124,6 +124,39 @@ class PageTest < ActiveSupport::TestCase
|
||||||
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_revise_changes_references_from_wanted_to_linked_for_redirected_pages
|
||||||
|
web = Web.find(1)
|
||||||
|
new_page = Page.new(:web => web, :name => 'NewPage')
|
||||||
|
new_page.revise('Reference to HappyPage, and to WantedPage2', 'NewPage', Time.now, 'AlexeyVerkhovsky',
|
||||||
|
test_renderer)
|
||||||
|
|
||||||
|
references = new_page.wiki_references(true)
|
||||||
|
assert_equal 2, references.size
|
||||||
|
assert_equal 'HappyPage', references[0].referenced_name
|
||||||
|
assert_equal WikiReference::WANTED_PAGE, references[0].link_type
|
||||||
|
assert_equal 'WantedPage2', references[1].referenced_name
|
||||||
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
|
|
||||||
|
my_page = Page.new(:web => web, :name => 'MyPage')
|
||||||
|
my_page.revise("[[!redirects HappyPage]]\nAnd here it is!", 'MyPage', Time.now, 'AlexeyVerkhovsky', test_renderer)
|
||||||
|
my_references = my_page.wiki_references(true)
|
||||||
|
assert_equal 1, my_references.size
|
||||||
|
assert_equal 'HappyPage', my_references[0].referenced_name
|
||||||
|
assert_equal WikiReference::REDIRECTED_PAGE, my_references[0].link_type
|
||||||
|
|
||||||
|
# link type stored for NewPage -> HappyPage reference should change from WANTED to LINKED
|
||||||
|
# reference NewPage -> WantedPage2 should remain the same
|
||||||
|
references = new_page.wiki_references(true)
|
||||||
|
assert_match( "Reference to <a class='existingWikiWord' href='\.\./show/MyPage'>Happy Page</a>",
|
||||||
|
test_renderer(new_page.revisions.last).display_content(true) )
|
||||||
|
assert_equal 2, references.size
|
||||||
|
assert_equal 'HappyPage', references[0].referenced_name
|
||||||
|
# Doesn't work, since picking up the change in wiki_references requires a database query.
|
||||||
|
# assert_equal WikiReference::LINKED_PAGE, references[0].link_type
|
||||||
|
assert_equal 'WantedPage2', references[1].referenced_name
|
||||||
|
assert_equal WikiReference::WANTED_PAGE, references[1].link_type
|
||||||
|
end
|
||||||
|
|
||||||
def test_rollback
|
def test_rollback
|
||||||
@page.revise("spot two", @page.name, Time.now, "David", test_renderer)
|
@page.revise("spot two", @page.name, Time.now, "David", test_renderer)
|
||||||
@page.revise("spot three", @page.name, Time.now + 2000, "David", test_renderer)
|
@page.revise("spot three", @page.name, Time.now + 2000, "David", test_renderer)
|
||||||
|
|
Loading…
Reference in a new issue