Cache clearing in Revision did not include wiki_reference_cache, which caused new pages to be created as orphans

This commit is contained in:
Alexey Verkhovsky 2005-04-03 05:15:56 +00:00
parent c0605f0b78
commit b1e92e3719
3 changed files with 24 additions and 10 deletions

View file

@ -88,8 +88,8 @@ class Revision
end end
def clear_display_cache def clear_display_cache
@wiki_references_cache = @published_cache = @display_cache = nil @wiki_words_cache = @published_cache = @display_cache = @wiki_includes_cache =
@wiki_includes_cache = nil @wiki_references_cache = nil
end end
def display_published def display_published

View file

@ -1,8 +1,8 @@
require "cgi" require 'cgi'
require "page" require 'page'
require "page_set" require 'page_set'
require "wiki_words" require 'wiki_words'
require "zip/zip" require 'zip/zip'
class Web class Web
attr_accessor :name, :password, :markup, :color, :safe_mode, :pages attr_accessor :name, :password, :markup, :color, :safe_mode, :pages
@ -35,7 +35,7 @@ class Web
def address=(the_address) def address=(the_address)
if the_address != CGI.escape(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 end
@address = the_address @address = the_address
end end
@ -162,6 +162,7 @@ class Web
end end
private private
# Returns an array of all the wiki words in any current revision # Returns an array of all the wiki words in any current revision
def wiki_words def wiki_words
pages.values.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq pages.values.inject([]) { |wiki_words, page| wiki_words << page.wiki_words }.flatten.uniq

View file

@ -126,6 +126,19 @@ class WebTest < Test::Unit::TestCase
} }
end 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 private
def add_sample_pages def add_sample_pages