From 621b79db55ac69566004dc4f864339053e334729 Mon Sep 17 00:00:00 2001 From: Alexey Verkhovsky Date: Sun, 16 Jan 2005 23:17:30 +0000 Subject: [PATCH] Tests for WikiService use default WikiService (with Madeleine persistence), not a WikiServiceWithNoPersistence. --- app/models/wiki_service.rb | 4 ++++ config/environments/test.rb | 4 +++- test/functional/wiki_controller_test.rb | 6 ++++-- test/unit/wiki_service_test.rb | 18 +++++++++++++++++- 4 files changed, 28 insertions(+), 4 deletions(-) diff --git a/app/models/wiki_service.rb b/app/models/wiki_service.rb index 8506039a..757afa6e 100755 --- a/app/models/wiki_service.rb +++ b/app/models/wiki_service.rb @@ -20,6 +20,10 @@ module AbstractWikiService @webs[address] = Web.new(name, address, password) unless @webs[address] end + def delete_web(address) + @webs[address] = nil + end + def init_wiki_service @webs = {} @system = {} diff --git a/config/environments/test.rb b/config/environments/test.rb index 6b1c6ea3..d4bad332 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -11,4 +11,6 @@ unless defined? TEST_LOGGER TEST_LOGGER = ActionController::Base.logger = Logger.new(log_name) ActionController::Base.logger.level = Logger::DEBUG -end \ No newline at end of file + + WikiService.storage_path = RAILS_ROOT + '/storage/test/' +end diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 00a7a3e0..d0851b6c 100755 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -158,7 +158,8 @@ class WikiControllerTest < Test::Unit::TestCase assert_success assert_equal 'application/zip', r.headers['Content-Type'] - assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, r.headers['Content-Disposition'] + assert_match /attachment; filename="wiki1-html-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, + r.headers['Content-Disposition'] # TODO assert contents of the output file end @@ -167,7 +168,8 @@ class WikiControllerTest < Test::Unit::TestCase assert_success assert_equal 'application/zip', r.headers['Content-Type'] - assert_match /attachment; filename="wiki1-textile-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, r.headers['Content-Disposition'] + assert_match /attachment; filename="wiki1-textile-\d\d\d\d-\d\d-\d\d-\d\d-\d\d-\d\d.zip"/, + r.headers['Content-Disposition'] # TODO assert contents of the output file end diff --git a/test/unit/wiki_service_test.rb b/test/unit/wiki_service_test.rb index 544ce870..641443dd 100755 --- a/test/unit/wiki_service_test.rb +++ b/test/unit/wiki_service_test.rb @@ -2,13 +2,29 @@ require File.dirname(__FILE__) + '/../test_helper' require 'wiki_service' +require 'fileutils' class WikiServiceTest < Test::Unit::TestCase + + # Clean the test storage directory before the run + unless defined? @@storage_cleaned + FileUtils.rm(Dir[RAILS_ROOT + 'storage/test/*.command_log']) + FileUtils.rm(Dir[RAILS_ROOT + 'storage/test/*.snapshot']) + FileUtils.rm(Dir[RAILS_ROOT + 'storage/test/*.tex']) + FileUtils.rm(Dir[RAILS_ROOT + 'storage/test/*.zip']) + FileUtils.rm(Dir[RAILS_ROOT + 'storage/test/*.pdf']) + @@cleaned_storage = true + end + def setup - @s = WikiServiceWithNoPersistence.new + @s = WikiService.instance @s.create_web 'Instiki', 'instiki' end + def teardown + @s.delete_web 'instiki' + end + def test_read_write_page @s.write_page 'instiki', 'FirstPage', "Electric shocks, I love 'em", Time.now, 'DavidHeinemeierHansson'