diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 852b47d5..31cbd687 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -2,7 +2,7 @@ # Likewise will all the methods added be available for all controllers. 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 # For injecting a different wiki model implementation. Intended for use in tests @@ -27,7 +27,7 @@ class ApplicationController < ActionController::Base end end - def fetch_model_data + def connect_to_model @action_name = @params['action'] || 'index' @web_name = @params['web'] @wiki = wiki diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index 0dc87f90..865450aa 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -9,6 +9,7 @@ class FileController < ApplicationController before_filter :check_allow_uploads def file + @file_name = params['id'] if @params['file'] # form supplied new_file = @web.wiki_files.create(@params['file']) @@ -65,10 +66,6 @@ class FileController < ApplicationController end end - def connect_to_model - super and @file_name = @params['id'] - end - private def import_from_archive(archive) diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index ac5cce45..6e7eec74 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -5,6 +5,7 @@ require 'zip/zip' class WikiController < ApplicationController + before_filter :load_page caches_action :show, :published, :authors, :recently_revised, :list cache_sweeper :revision_sweeper @@ -284,8 +285,7 @@ class WikiController < ApplicationController protected - def connect_to_model - super + def load_page @page_name = @params['id'] @page = @wiki.read_page(@web_name, @page_name) if @page_name end diff --git a/test/test_helper.rb b/test/test_helper.rb index 2dae41c9..3afd1ae6 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -13,10 +13,8 @@ require 'breakpoint' require 'wiki_content' require 'url_generator' -# Uncomment these and hang on, because the tests will be FAST -#Test::Unit::TestCase.pre_loaded_fixtures = false -#Test::Unit::TestCase.use_transactional_fixtures = true - +Test::Unit::TestCase.pre_loaded_fixtures = false +Test::Unit::TestCase.use_transactional_fixtures = true Test::Unit::TestCase.use_instantiated_fixtures = false Test::Unit::TestCase.fixture_path = File.dirname(__FILE__) + "/fixtures/" diff --git a/test/unit/web_test.rb b/test/unit/web_test.rb index 57f47ea7..62c3935e 100644 --- a/test/unit/web_test.rb +++ b/test/unit/web_test.rb @@ -19,7 +19,7 @@ class WebTest < Test::Unit::TestCase assert_equal 0, @web.select { |page| page.content =~ /none/i }.length end - def test_references + def test_002_references add_sample_pages assert_equal 1, @web.select.pages_that_reference('EverBeenHated').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') end - def test_orphaned_pages + def test_001_orphaned_pages add_sample_pages home = @web.add_page('HomePage', 'This is a home page, it should not be an orphan',