Deleted all references to PageRenderer from PageSet selectors; using wiki_references instead

This commit is contained in:
Alexey Verkhovsky 2005-09-11 08:05:19 +00:00
parent bec3c98227
commit 541a5d3994
7 changed files with 16 additions and 13 deletions

View file

@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base
before_filter :set_utf8_http_header, :connect_to_model, :setup_url_generator
after_filter :remember_location, :teardown_url_generator
observer :page_observer
# For injecting a different wiki model implementation. Intended for use in tests
def self.wiki=(the_wiki)
# a global variable is used here because Rails reloads controller and model classes in the

View file

@ -4,10 +4,6 @@ class Page < ActiveRecord::Base
has_many :wiki_references, :order => 'referenced_page_name'
has_one :current_revision, :class_name => 'Revision', :order => 'id DESC'
def before_create
WikiReference.register_page_creation(self)
end
def revise(content, time, author, renderer)
revisions_size = new_record? ? 0 : revisions.size
if (revisions_size > 0) and content == current_revision.content

View file

@ -31,15 +31,18 @@ class PageSet < Array
end
def pages_that_reference(page_name)
self.select { |page| PageRenderer.new(page.revisions.last).wiki_references.include?(page_name) }
all_referring_pages = WikiReference.pages_that_reference(page_name)
self.select { |page| all_referring_pages.include?(page.name) }
end
def pages_that_link_to(page_name)
self.select { |page| PageRenderer.new(page.revisions.last).wiki_words.include?(page_name) }
all_linking_pages = WikiReference.pages_that_link_to(page_name)
self.select { |page| all_linking_pages.include?(page.name) }
end
def pages_that_include(page_name)
self.select { |page| PageRenderer.new(page.revisions.last).wiki_includes.include?(page_name) }
all_including_pages = WikiReference.pages_that_include(page_name)
self.select { |page| all_including_pages.include?(page.name) }
end
def pages_authored_by(author)
@ -78,7 +81,7 @@ class PageSet < Array
end
def wiki_words
self.inject([]) { |wiki_words, page| wiki_words << PageRenderer.new(page.revisions.last).wiki_words }.flatten.uniq
self.inject([]) { |wiki_words, page| WikiReference.wiki_words(page) }.flatten.uniq
end
def authors

View file

@ -7,7 +7,7 @@ require 'admin_controller'
class AdminController; def rescue_action(e) logger.error(e); raise e end; end
class AdminControllerTest < Test::Unit::TestCase
fixtures :webs, :pages, :revisions, :system
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup
@controller = AdminController.new
@ -204,7 +204,6 @@ class AdminControllerTest < Test::Unit::TestCase
assert_equal page_order, @web.select.sort,
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
# Oak is now orphan, second pass should remove it
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password_orphaned' => 'pswd')
assert_redirected_to :controller => 'wiki', :web => 'wiki1', :action => 'list'

View file

@ -14,7 +14,7 @@ require 'zip/zipfilesystem'
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
class WikiControllerTest < Test::Unit::TestCase
fixtures :webs, :pages, :revisions, :system
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup
@controller = WikiController.new

View file

@ -20,6 +20,9 @@ require 'url_generator'
Test::Unit::TestCase.use_instantiated_fixtures = false
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
# activate PageObserver
PageObserver.instance
class Test::Unit::TestCase
def create_fixtures(*table_names)
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)

View file

@ -1,7 +1,7 @@
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
class WebTest < Test::Unit::TestCase
fixtures :webs, :pages, :revisions, :system
fixtures :webs, :pages, :revisions, :system, :wiki_references
def setup
@web = webs(:instiki)
@ -78,7 +78,7 @@ class WebTest < Test::Unit::TestCase
'This is an author page, it should not be an orphan',
Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', test_renderer)
self_linked = @web.add_page('SelfLinked',
'I am me SelfLinked and link to EverBeenInLove',
'I am SelfLinked and link to EverBeenInLove',
Time.local(2004, 4, 4, 16, 50), 'AnonymousCoward', test_renderer)
# page that links to itself, and nobody else links to it must be an orphan