Deleted all references to PageRenderer from PageSet selectors; using wiki_references instead
This commit is contained in:
parent
bec3c98227
commit
541a5d3994
|
@ -5,6 +5,8 @@ class ApplicationController < ActionController::Base
|
||||||
before_filter :set_utf8_http_header, :connect_to_model, :setup_url_generator
|
before_filter :set_utf8_http_header, :connect_to_model, :setup_url_generator
|
||||||
after_filter :remember_location, :teardown_url_generator
|
after_filter :remember_location, :teardown_url_generator
|
||||||
|
|
||||||
|
observer :page_observer
|
||||||
|
|
||||||
# For injecting a different wiki model implementation. Intended for use in tests
|
# For injecting a different wiki model implementation. Intended for use in tests
|
||||||
def self.wiki=(the_wiki)
|
def self.wiki=(the_wiki)
|
||||||
# a global variable is used here because Rails reloads controller and model classes in the
|
# a global variable is used here because Rails reloads controller and model classes in the
|
||||||
|
|
|
@ -4,10 +4,6 @@ class Page < ActiveRecord::Base
|
||||||
has_many :wiki_references, :order => 'referenced_page_name'
|
has_many :wiki_references, :order => 'referenced_page_name'
|
||||||
has_one :current_revision, :class_name => 'Revision', :order => 'id DESC'
|
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)
|
def revise(content, time, author, renderer)
|
||||||
revisions_size = new_record? ? 0 : revisions.size
|
revisions_size = new_record? ? 0 : revisions.size
|
||||||
if (revisions_size > 0) and content == current_revision.content
|
if (revisions_size > 0) and content == current_revision.content
|
||||||
|
|
|
@ -31,15 +31,18 @@ class PageSet < Array
|
||||||
end
|
end
|
||||||
|
|
||||||
def pages_that_reference(page_name)
|
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
|
end
|
||||||
|
|
||||||
def pages_that_link_to(page_name)
|
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
|
end
|
||||||
|
|
||||||
def pages_that_include(page_name)
|
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
|
end
|
||||||
|
|
||||||
def pages_authored_by(author)
|
def pages_authored_by(author)
|
||||||
|
@ -78,7 +81,7 @@ class PageSet < Array
|
||||||
end
|
end
|
||||||
|
|
||||||
def wiki_words
|
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
|
end
|
||||||
|
|
||||||
def authors
|
def authors
|
||||||
|
|
|
@ -7,7 +7,7 @@ require 'admin_controller'
|
||||||
class AdminController; def rescue_action(e) logger.error(e); raise e end; end
|
class AdminController; def rescue_action(e) logger.error(e); raise e end; end
|
||||||
|
|
||||||
class AdminControllerTest < Test::Unit::TestCase
|
class AdminControllerTest < Test::Unit::TestCase
|
||||||
fixtures :webs, :pages, :revisions, :system
|
fixtures :webs, :pages, :revisions, :system, :wiki_references
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = AdminController.new
|
@controller = AdminController.new
|
||||||
|
@ -204,7 +204,6 @@ class AdminControllerTest < Test::Unit::TestCase
|
||||||
assert_equal page_order, @web.select.sort,
|
assert_equal page_order, @web.select.sort,
|
||||||
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
"Pages are not as expected: #{@web.select.sort.map {|p| p.name}.inspect}"
|
||||||
|
|
||||||
|
|
||||||
# Oak is now orphan, second pass should remove it
|
# Oak is now orphan, second pass should remove it
|
||||||
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password_orphaned' => 'pswd')
|
r = process('remove_orphaned_pages', 'web' => 'wiki1', 'system_password_orphaned' => 'pswd')
|
||||||
assert_redirected_to :controller => 'wiki', :web => 'wiki1', :action => 'list'
|
assert_redirected_to :controller => 'wiki', :web => 'wiki1', :action => 'list'
|
||||||
|
|
|
@ -14,7 +14,7 @@ require 'zip/zipfilesystem'
|
||||||
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
|
class WikiController; def rescue_action(e) logger.error(e); raise e end; end
|
||||||
|
|
||||||
class WikiControllerTest < Test::Unit::TestCase
|
class WikiControllerTest < Test::Unit::TestCase
|
||||||
fixtures :webs, :pages, :revisions, :system
|
fixtures :webs, :pages, :revisions, :system, :wiki_references
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@controller = WikiController.new
|
@controller = WikiController.new
|
||||||
|
|
|
@ -20,6 +20,9 @@ require 'url_generator'
|
||||||
Test::Unit::TestCase.use_instantiated_fixtures = false
|
Test::Unit::TestCase.use_instantiated_fixtures = false
|
||||||
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/"
|
||||||
|
|
||||||
|
# activate PageObserver
|
||||||
|
PageObserver.instance
|
||||||
|
|
||||||
class Test::Unit::TestCase
|
class Test::Unit::TestCase
|
||||||
def create_fixtures(*table_names)
|
def create_fixtures(*table_names)
|
||||||
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
|
Fixtures.create_fixtures(File.dirname(__FILE__) + "/fixtures", table_names)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
|
||||||
|
|
||||||
class WebTest < Test::Unit::TestCase
|
class WebTest < Test::Unit::TestCase
|
||||||
fixtures :webs, :pages, :revisions, :system
|
fixtures :webs, :pages, :revisions, :system, :wiki_references
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@web = webs(:instiki)
|
@web = webs(:instiki)
|
||||||
|
@ -78,7 +78,7 @@ class WebTest < Test::Unit::TestCase
|
||||||
'This is an author page, it should not be an orphan',
|
'This is an author page, it should not be an orphan',
|
||||||
Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', test_renderer)
|
Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky', test_renderer)
|
||||||
self_linked = @web.add_page('SelfLinked',
|
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)
|
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
|
# page that links to itself, and nobody else links to it must be an orphan
|
||||||
|
|
Loading…
Reference in a new issue