Cache clearing in Revision did not include wiki_reference_cache, which caused new pages to be created as orphans
This commit is contained in:
parent
c0605f0b78
commit
b1e92e3719
3 changed files with 24 additions and 10 deletions
|
@ -54,12 +54,12 @@ class Revision
|
|||
|
||||
# Returns an array of all the WikiWords present in the content of this revision.
|
||||
def wiki_words
|
||||
unless @wiki_words_cache
|
||||
unless @wiki_words_cache
|
||||
wiki_chunks = display_content.find_chunks(WikiChunk::WikiLink)
|
||||
@wiki_words_cache = wiki_chunks.map { |c| ( c.escaped? ? nil : c.page_name ) }.compact.uniq
|
||||
end
|
||||
@wiki_words_cache
|
||||
end
|
||||
end
|
||||
|
||||
# Returns an array of all the WikiWords present in the content of this revision.
|
||||
# that already exists as a page in the web.
|
||||
|
@ -88,8 +88,8 @@ class Revision
|
|||
end
|
||||
|
||||
def clear_display_cache
|
||||
@wiki_references_cache = @published_cache = @display_cache = nil
|
||||
@wiki_includes_cache = nil
|
||||
@wiki_words_cache = @published_cache = @display_cache = @wiki_includes_cache =
|
||||
@wiki_references_cache = nil
|
||||
end
|
||||
|
||||
def display_published
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
require "cgi"
|
||||
require "page"
|
||||
require "page_set"
|
||||
require "wiki_words"
|
||||
require "zip/zip"
|
||||
require 'cgi'
|
||||
require 'page'
|
||||
require 'page_set'
|
||||
require 'wiki_words'
|
||||
require 'zip/zip'
|
||||
|
||||
class Web
|
||||
attr_accessor :name, :password, :markup, :color, :safe_mode, :pages
|
||||
|
@ -35,7 +35,7 @@ class Web
|
|||
|
||||
def address=(the_address)
|
||||
if the_address != CGI.escape(the_address)
|
||||
raise Instiki::ValidationError.new("Web name should contain only valid URI characters")
|
||||
raise Instiki::ValidationError.new('Web name should contain only valid URI characters')
|
||||
end
|
||||
@address = the_address
|
||||
end
|
||||
|
@ -162,6 +162,7 @@ class Web
|
|||
end
|
||||
|
||||
private
|
||||
|
||||
# Returns an array of all the wiki words in any current revision
|
||||
def wiki_words
|
||||
pages.values.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq
|
||||
|
|
|
@ -126,6 +126,19 @@ class WebTest < Test::Unit::TestCase
|
|||
}
|
||||
end
|
||||
|
||||
def test_new_page_linked_from_mother_page
|
||||
# this was a bug in revision 204
|
||||
home = Page.new(@web, 'HomePage', 'This page refers to AnotherPage',
|
||||
Time.local(2004, 4, 4, 16, 50), 'Alexey Verkhovsky')
|
||||
another_page = Page.new(@web, 'AnotherPage', 'This is \AnotherPage',
|
||||
Time.local(2004, 4, 4, 16, 51), 'Alexey Verkhovsky')
|
||||
|
||||
@web.add_page(home)
|
||||
@web.add_page(another_page)
|
||||
|
||||
assert_equal [home], @web.select.pages_that_link_to('AnotherPage')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def add_sample_pages
|
||||
|
|
Loading…
Reference in a new issue