Corrected WikiReference::link_type when a newly created page refers to itself (should be 'L', not 'W')

This commit is contained in:
Alexey Verkhovsky 2005-09-11 05:59:21 +00:00
parent cd68db01d2
commit 0c6626c375
2 changed files with 14 additions and 3 deletions

View file

@ -94,9 +94,15 @@ class PageRenderer
wiki_words = wiki_word_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq wiki_words = wiki_word_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
wiki_words.each do |referenced_page_name| wiki_words.each do |referenced_page_name|
# Links to self are always considered linked
if referenced_page_name == @revision.page.name
link_type = WikiReference::LINKED_PAGE
else
link_type = WikiReference.link_type(@revision.page.web, referenced_page_name)
end
@revision.page.wiki_references.create({ @revision.page.wiki_references.create({
:referenced_page_name => referenced_page_name, :referenced_page_name => referenced_page_name,
:link_type => WikiReference.link_type(@revision.page.web, referenced_page_name) :link_type => link_type
}) })
end end
result result

View file

@ -328,13 +328,18 @@ class PageRendererTest < Test::Unit::TestCase
# Tests for the caching of wiki references and categories # Tests for the caching of wiki references and categories
def test_references_creation def test_references_creation
new_page = @web.add_page('NewPage', 'HomePage', new_page = @web.add_page('NewPage', 'HomePage NewPage',
Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', test_renderer) Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', test_renderer)
references = new_page.wiki_references(true) references = new_page.wiki_references(true)
assert_equal 1, references.size assert_equal 2, references.size
assert_equal 'HomePage', references[0].referenced_page_name assert_equal 'HomePage', references[0].referenced_page_name
assert_equal WikiReference::LINKED_PAGE, references[0].link_type assert_equal WikiReference::LINKED_PAGE, references[0].link_type
assert_equal 'NewPage', references[1].referenced_page_name
assert_equal WikiReference::LINKED_PAGE, references[1].link_type
end
def test_rendering_changes_references_from_wanted_to_linked
end end
private private