Fixed connect_to_model filter extension in wiki_controller (using inheritance here was daft); accelerated tests somewhat
This commit is contained in:
parent
64313ca208
commit
5f3cf38851
|
@ -2,7 +2,7 @@
|
||||||
# Likewise will all the methods added be available for all controllers.
|
# Likewise will all the methods added be available for all controllers.
|
||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
before_filter :fetch_model_data, :check_authorization, :setup_url_generator, :set_content_type_header, :set_robots_metatag
|
before_filter :connect_to_model, :check_authorization, :setup_url_generator, :set_content_type_header, :set_robots_metatag
|
||||||
after_filter :remember_location, :teardown_url_generator
|
after_filter :remember_location, :teardown_url_generator
|
||||||
|
|
||||||
# For injecting a different wiki model implementation. Intended for use in tests
|
# For injecting a different wiki model implementation. Intended for use in tests
|
||||||
|
@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_model_data
|
def connect_to_model
|
||||||
@action_name = @params['action'] || 'index'
|
@action_name = @params['action'] || 'index'
|
||||||
@web_name = @params['web']
|
@web_name = @params['web']
|
||||||
@wiki = wiki
|
@wiki = wiki
|
||||||
|
|
|
@ -9,6 +9,7 @@ class FileController < ApplicationController
|
||||||
before_filter :check_allow_uploads
|
before_filter :check_allow_uploads
|
||||||
|
|
||||||
def file
|
def file
|
||||||
|
@file_name = params['id']
|
||||||
if @params['file']
|
if @params['file']
|
||||||
# form supplied
|
# form supplied
|
||||||
new_file = @web.wiki_files.create(@params['file'])
|
new_file = @web.wiki_files.create(@params['file'])
|
||||||
|
@ -65,10 +66,6 @@ class FileController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def connect_to_model
|
|
||||||
super and @file_name = @params['id']
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def import_from_archive(archive)
|
def import_from_archive(archive)
|
||||||
|
|
|
@ -5,6 +5,7 @@ require 'zip/zip'
|
||||||
|
|
||||||
class WikiController < ApplicationController
|
class WikiController < ApplicationController
|
||||||
|
|
||||||
|
before_filter :load_page
|
||||||
caches_action :show, :published, :authors, :recently_revised, :list
|
caches_action :show, :published, :authors, :recently_revised, :list
|
||||||
cache_sweeper :revision_sweeper
|
cache_sweeper :revision_sweeper
|
||||||
|
|
||||||
|
@ -284,8 +285,7 @@ class WikiController < ApplicationController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def connect_to_model
|
def load_page
|
||||||
super
|
|
||||||
@page_name = @params['id']
|
@page_name = @params['id']
|
||||||
@page = @wiki.read_page(@web_name, @page_name) if @page_name
|
@page = @wiki.read_page(@web_name, @page_name) if @page_name
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,10 +13,8 @@ require 'breakpoint'
|
||||||
require 'wiki_content'
|
require 'wiki_content'
|
||||||
require 'url_generator'
|
require 'url_generator'
|
||||||
|
|
||||||
# Uncomment these and hang on, because the tests will be FAST
|
Test::Unit::TestCase.pre_loaded_fixtures = false
|
||||||
#Test::Unit::TestCase.pre_loaded_fixtures = false
|
Test::Unit::TestCase.use_transactional_fixtures = true
|
||||||
#Test::Unit::TestCase.use_transactional_fixtures = true
|
|
||||||
|
|
||||||
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/"
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ class WebTest < Test::Unit::TestCase
|
||||||
assert_equal 0, @web.select { |page| page.content =~ /none/i }.length
|
assert_equal 0, @web.select { |page| page.content =~ /none/i }.length
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_references
|
def test_002_references
|
||||||
add_sample_pages
|
add_sample_pages
|
||||||
assert_equal 1, @web.select.pages_that_reference('EverBeenHated').length
|
assert_equal 1, @web.select.pages_that_reference('EverBeenHated').length
|
||||||
assert_equal 0, @web.select.pages_that_reference('EverBeenInLove').length
|
assert_equal 0, @web.select.pages_that_reference('EverBeenInLove').length
|
||||||
|
@ -69,7 +69,7 @@ class WebTest < Test::Unit::TestCase
|
||||||
assert_equal [home], @web.select.pages_that_link_to('AnotherPage')
|
assert_equal [home], @web.select.pages_that_link_to('AnotherPage')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_orphaned_pages
|
def test_001_orphaned_pages
|
||||||
add_sample_pages
|
add_sample_pages
|
||||||
home = @web.add_page('HomePage',
|
home = @web.add_page('HomePage',
|
||||||
'This is a home page, it should not be an orphan',
|
'This is a home page, it should not be an orphan',
|
||||||
|
|
Loading…
Reference in a new issue