Corrected WikiReference::link_type when a newly created page refers to itself (should be 'L', not 'W')
This commit is contained in:
parent
cd68db01d2
commit
0c6626c375
|
@ -94,9 +94,15 @@ class PageRenderer
|
|||
wiki_words = wiki_word_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
|
||||
|
||||
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({
|
||||
:referenced_page_name => referenced_page_name,
|
||||
:link_type => WikiReference.link_type(@revision.page.web, referenced_page_name)
|
||||
:link_type => link_type
|
||||
})
|
||||
end
|
||||
result
|
||||
|
|
|
@ -328,13 +328,18 @@ class PageRendererTest < Test::Unit::TestCase
|
|||
|
||||
# Tests for the caching of wiki references and categories
|
||||
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)
|
||||
|
||||
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 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
|
||||
|
||||
private
|
||||
|
|
Loading…
Reference in a new issue