Tests for WikiService use default WikiService (with Madeleine persistence), not a WikiServiceWithNoPersistence.
This commit is contained in:
parent
ab63f1449d
commit
621b79db55
4 changed files with 28 additions and 4 deletions
|
@ -20,6 +20,10 @@ module AbstractWikiService
|
||||||
@webs[address] = Web.new(name, address, password) unless @webs[address]
|
@webs[address] = Web.new(name, address, password) unless @webs[address]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_web(address)
|
||||||
|
@webs[address] = nil
|
||||||
|
end
|
||||||
|
|
||||||
def init_wiki_service
|
def init_wiki_service
|
||||||
@webs = {}
|
@webs = {}
|
||||||
@system = {}
|
@system = {}
|
||||||
|
|
|
@ -11,4 +11,6 @@ unless defined? TEST_LOGGER
|
||||||
|
|
||||||
TEST_LOGGER = ActionController::Base.logger = Logger.new(log_name)
|
TEST_LOGGER = ActionController::Base.logger = Logger.new(log_name)
|
||||||
ActionController::Base.logger.level = Logger::DEBUG
|
ActionController::Base.logger.level = Logger::DEBUG
|
||||||
|
|
||||||
|
WikiService.storage_path = RAILS_ROOT + '/storage/test/'
|
||||||
end
|
end
|
|
@ -158,7 +158,8 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_equal 'application/zip', r.headers['Content-Type']
|
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
|
# TODO assert contents of the output file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -167,7 +168,8 @@ class WikiControllerTest < Test::Unit::TestCase
|
||||||
|
|
||||||
assert_success
|
assert_success
|
||||||
assert_equal 'application/zip', r.headers['Content-Type']
|
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
|
# TODO assert contents of the output file
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,29 @@
|
||||||
|
|
||||||
require File.dirname(__FILE__) + '/../test_helper'
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
require 'wiki_service'
|
require 'wiki_service'
|
||||||
|
require 'fileutils'
|
||||||
|
|
||||||
class WikiServiceTest < Test::Unit::TestCase
|
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
|
def setup
|
||||||
@s = WikiServiceWithNoPersistence.new
|
@s = WikiService.instance
|
||||||
@s.create_web 'Instiki', 'instiki'
|
@s.create_web 'Instiki', 'instiki'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
@s.delete_web 'instiki'
|
||||||
|
end
|
||||||
|
|
||||||
def test_read_write_page
|
def test_read_write_page
|
||||||
@s.write_page 'instiki', 'FirstPage', "Electric shocks, I love 'em",
|
@s.write_page 'instiki', 'FirstPage', "Electric shocks, I love 'em",
|
||||||
Time.now, 'DavidHeinemeierHansson'
|
Time.now, 'DavidHeinemeierHansson'
|
||||||
|
|
Loading…
Reference in a new issue