From 8c331d101975769ed8b66c4df29fc0eee196a587 Mon Sep 17 00:00:00 2001 From: Rick Okin Date: Tue, 9 Aug 2005 01:28:19 +0000 Subject: [PATCH] moved old test stuff --- test-old/all_tests.rb | 9 - test-old/test_helper.rb | 129 ------- test-old/unit/page_test.rb | 89 ----- test-old/unit/revision_test.rb | 335 ------------------ test-old/unit/web_test.rb | 165 --------- test-old/unit/wiki_service_test.rb | 129 ------- {test-old => test}/fixtures/rails.gif | Bin .../functional/admin_controller_test.rb | 0 .../functional/application_test.rb | 0 .../functional/file_controller_test.rb | 0 test/{ => functional}/routes_test.rb | 0 .../functional/wiki_controller_test.rb | 0 {test-old => test}/watir/e2e.rb | 0 13 files changed, 856 deletions(-) delete mode 100755 test-old/all_tests.rb delete mode 100644 test-old/test_helper.rb delete mode 100755 test-old/unit/page_test.rb delete mode 100755 test-old/unit/revision_test.rb delete mode 100755 test-old/unit/web_test.rb delete mode 100755 test-old/unit/wiki_service_test.rb rename {test-old => test}/fixtures/rails.gif (100%) rename {test-old => test}/functional/admin_controller_test.rb (100%) rename {test-old => test}/functional/application_test.rb (100%) rename {test-old => test}/functional/file_controller_test.rb (100%) rename test/{ => functional}/routes_test.rb (100%) rename {test-old => test}/functional/wiki_controller_test.rb (100%) rename {test-old => test}/watir/e2e.rb (100%) diff --git a/test-old/all_tests.rb b/test-old/all_tests.rb deleted file mode 100755 index 023ee389..00000000 --- a/test-old/all_tests.rb +++ /dev/null @@ -1,9 +0,0 @@ -require 'test_helper' -require 'find' - -test_root = File.dirname(__FILE__) -Find.find(test_root) { |path| - if File.file?(path) and path =~ /.*_test\.rb$/ - load path - end -} diff --git a/test-old/test_helper.rb b/test-old/test_helper.rb deleted file mode 100644 index fe8c1e29..00000000 --- a/test-old/test_helper.rb +++ /dev/null @@ -1,129 +0,0 @@ -ENV['RAILS_ENV'] = 'test' -require File.expand_path(File.dirname(__FILE__) + '/../config/environment') -require 'application' -require 'test/unit' -require 'breakpoint' -require 'action_controller/test_process' - -# Uncomment this variable to have assert_success check that response bodies are valid XML -$validate_xml_in_assert_success = true - -# Convenient setup method for Test::Unit::TestCase -class Test::Unit::TestCase - - private - - def setup_controller_test(controller_class = nil, host = nil) - if controller_class - @controller = controller_class.new - elsif self.class.to_s =~ /^(\w+Controller)Test$/ - @controller = Object::const_get($1).new - else - raise "Cannot derive the name of controller under test from class name #{self.class}" - end - @request, @response = ActionController::TestRequest.new, ActionController::TestResponse.new - @request.host = host || 'localhost' - return @request, @response - end - - # Wiki fixture for tests - - def setup_test_wiki - @wiki = ApplicationController.wiki = WikiServiceWithNoPersistence.new - @web = @wiki.create_web('Test Wiki 1', 'wiki1') - @home = @wiki.write_page('wiki1', 'HomePage', 'First revision of the HomePage end', Time.now, - Author.new('AnAuthor', '127.0.0.1')) - end - - def setup_wiki_with_three_pages - @oak = @wiki.write_page('wiki1', 'Oak', - "All about oak.\n" + - "category: trees", - 5.minutes.ago, Author.new('TreeHugger', '127.0.0.2')) - @elephant = @wiki.write_page('wiki1', 'Elephant', - "All about elephants.\n" + - "category: animals", - 10.minutes.ago, Author.new('Guest', '127.0.0.2')) - end - - def setup_wiki_with_30_pages - (1..30).each { |i| - @wiki.write_page('wiki1', "page#{i}", "Test page #{i}\ncategory: test", - Time.local(1976, 10, i, 12, 00, 00), Author.new('Dema', '127.0.0.2')) - } - end - - def tear_down_wiki - ApplicationController.wiki = nil - end - -end - -class WikiServiceWithNoPersistence - include AbstractWikiService - def initialize - init_wiki_service - end - - def storage_path - RAILS_ROOT + '/storage/test/' - end -end - - -# This module is to be included in unit tests that involve matching chunks. -# It provides a easy way to test whether a chunk matches a particular string -# and any the values of any fields that should be set after a match. -class ContentStub < String - include ChunkManager - def initialize(str) - super - init_chunk_manager - end - def page_link(*); end -end - -module ChunkMatch - - # Asserts a number of tests for the given type and text. - def match(chunk_type, test_text, expected_chunk_state) - if chunk_type.respond_to? :pattern - assert_match(chunk_type.pattern, test_text) - end - - content = ContentStub.new(test_text) - chunk_type.apply_to(content) - - # Test if requested parts are correct. - expected_chunk_state.each_pair do |a_method, expected_value| - assert content.chunks.last.kind_of?(chunk_type) - assert_respond_to(content.chunks.last, a_method) - assert_equal(expected_value, content.chunks.last.send(a_method.to_sym), - "Wrong #{a_method} value") - end - end - - # Asserts that test_text doesn't match the chunk_type - def no_match(chunk_type, test_text) - if chunk_type.respond_to? :pattern - assert_no_match(chunk_type.pattern, test_text) - end - end -end - -if defined? $validate_xml_in_assert_success and $validate_xml_in_assert_success == true - module Test - module Unit - module Assertions - unless method_defined? :__assert_success_before_ovverride_by_instiki - alias :__assert_success_before_ovverride_by_instiki :assert_success - end - def assert_success - __assert_success_before_ovverride_by_instiki - if @response.body.kind_of?(Proc) then # it's a file download, not an HTML content - else assert_nothing_raised(@response.body) { REXML::Document.new(@response.body) } end - end - end - end - end -end diff --git a/test-old/unit/page_test.rb b/test-old/unit/page_test.rb deleted file mode 100755 index 050bc8cd..00000000 --- a/test-old/unit/page_test.rb +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/env ruby -w - -require File.dirname(__FILE__) + '/../test_helper' -require 'web' -require 'page' - -class PageTest < Test::Unit::TestCase - - class MockWeb < Web - def initialize() super(nil, 'test','test') end - def [](wiki_word) %w( MyWay ThatWay SmartEngine ).include?(wiki_word) end - def refresh_pages_with_references(name) end - end - - def setup - @page = Page.new(MockWeb.new, "FirstPage") - @page.revise("HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \\OverThere -- see SmartEngine in that SmartEngineGUI", - Time.local(2004, 4, 4, 16, 50), - "DavidHeinemeierHansson") - end - - def test_lock - assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) - - @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") - - assert @page.locked?(Time.local(2004, 4, 4, 16, 50)) - assert !@page.locked?(Time.local(2004, 4, 4, 17, 1)) - - @page.unlock - - assert !@page.locked?(Time.local(2004, 4, 4, 16, 50)) - end - - def test_lock_duration - @page.lock(Time.local(2004, 4, 4, 16, 30), "DavidHeinemeierHansson") - - assert_equal 15, @page.lock_duration(Time.local(2004, 4, 4, 16, 45)) - end - - def test_plain_name - assert_equal "First Page", @page.plain_name - end - - def test_revise - @page.revise('HisWay would be MyWay in kinda lame', Time.local(2004, 4, 4, 16, 55), 'MarianneSyhler') - assert_equal 2, @page.revisions.length, 'Should have two revisions' - assert_equal 'MarianneSyhler', @page.author, 'Mary should be the author now' - assert_equal 'DavidHeinemeierHansson', @page.revisions.first.author, 'David was the first author' - end - - def test_revise_continous_revision - @page.revise('HisWay would be MyWay in kinda lame', Time.local(2004, 4, 4, 16, 55), 'MarianneSyhler') - assert_equal 2, @page.revisions.length - - @page.revise('HisWay would be MyWay in kinda update', Time.local(2004, 4, 4, 16, 57), 'MarianneSyhler') - assert_equal 2, @page.revisions.length - assert_equal 'HisWay would be MyWay in kinda update', @page.revisions.last.content - assert_equal Time.local(2004, 4, 4, 16, 57), @page.revisions.last.created_at - - @page.revise('HisWay would be MyWay in the house', Time.local(2004, 4, 4, 16, 58), 'DavidHeinemeierHansson') - assert_equal 3, @page.revisions.length - assert_equal 'HisWay would be MyWay in the house', @page.revisions.last.content - - @page.revise('HisWay would be MyWay in my way', Time.local(2004, 4, 4, 17, 30), 'DavidHeinemeierHansson') - assert_equal 4, @page.revisions.length - end - - def test_revise_content_unchanged - last_revision_before = @page.revisions.last - revisions_number_before = @page.revisions.size - - assert_raises(Instiki::ValidationError) { - @page.revise(@page.revisions.last.content.dup, Time.now, 'AlexeyVerkhovsky') - } - - assert_same last_revision_before, @page.revisions.last - assert_equal revisions_number_before, @page.revisions.size - end - - def test_rollback - @page.revise("spot two", Time.now, "David") - @page.revise("spot three", Time.now + 2000, "David") - assert_equal 3, @page.revisions.length, "Should have three revisions" - @page.rollback(1, Time.now) - assert_equal "spot two", @page.content - end - -end diff --git a/test-old/unit/revision_test.rb b/test-old/unit/revision_test.rb deleted file mode 100755 index bd84e660..00000000 --- a/test-old/unit/revision_test.rb +++ /dev/null @@ -1,335 +0,0 @@ -#!/bin/env ruby -w - -require File.dirname(__FILE__) + '/../test_helper' -require 'web' -require 'revision' -require 'fileutils' - -class RevisionTest < Test::Unit::TestCase - - def setup - setup_test_wiki - @web.markup = :textile - - @page = @wiki.read_page('wiki1', 'HomePage') - ['MyWay', 'SmartEngine', 'ThatWay'].each do |page| - @wiki.write_page('wiki1', page, page, Time.now, 'Me') - end - @wiki.write_page('wiki1','NoWikiWord', 'hey you', Time.now, 'Me') - - @revision = Revision.new(@page, 1, - 'HisWay would be MyWay in kinda ThatWay in HisWay though MyWay \OverThere -- ' + - 'see SmartEngine in that SmartEngineGUI', - Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson') - end - - def test_wiki_words - assert_equal %w( HisWay MyWay SmartEngine SmartEngineGUI ThatWay ), @revision.wiki_words.sort - - @wiki.write_page('wiki1', 'NoWikiWord', 'hey you', Time.now, 'Me') - assert_equal [], @wiki.read_page('wiki1', 'NoWikiWord').wiki_words - end - - def test_existing_pages - assert_equal %w( MyWay SmartEngine ThatWay ), @revision.existing_pages.sort - end - - def test_unexisting_pages - assert_equal %w( HisWay SmartEngineGUI ), @revision.unexisting_pages.sort - end - - def test_content_with_wiki_links - assert_equal '

His Way? ' + - 'would be My Way in kinda ' + - 'That Way in ' + - 'His Way? ' + - 'though My Way OverThere—see ' + - 'Smart Engine in that ' + - 'Smart Engine GUI' + - '?

', - @revision.display_content - end - - def test_markdown - @web.markup = :markdown - - assert_markup_parsed_as( - %{

My Headline

\n\n

that } + - %{Smart Engine GUI?

}, - "My Headline\n===========\n\nthat SmartEngineGUI") - - code_block = [ - 'This is a code block:', - '', - ' def a_method(arg)', - ' return ThatWay', - '', - 'Nice!' - ].join("\n") - - assert_markup_parsed_as( - %{

This is a code block:

\n\n
def a_method(arg)\n} +
-	    %{return ThatWay\n
\n\n

Nice!

}, - code_block) - end - - def test_markdown_hyperlink_with_slash - # in response to a bug, see http://dev.instiki.org/attachment/ticket/177 - @web.markup = :markdown - - assert_markup_parsed_as( - '

text

', - '[text](http://example/with/slash)') - end - - def test_mixed_formatting - - textile_and_markdown = [ - 'Markdown heading', - '================', - '', - 'h2. Textile heading', - '', - '*some* **text** _with_ -styles-', - '', - '* list 1', - '* list 2' - ].join("\n") - - @web.markup = :markdown - assert_markup_parsed_as( - "

Markdown heading

\n\n" + - "

h2. Textile heading

\n\n" + - "

some text with -styles-

\n\n" + - "", - textile_and_markdown) - - @web.markup = :textile - assert_markup_parsed_as( - "

Markdown heading
================

\n\n\n\t

Textile heading

" + - "\n\n\n\t

some text with styles

" + - "\n\n\n\t", - textile_and_markdown) - - @web.markup = :mixed - assert_markup_parsed_as( - "

Markdown heading

\n\n\n\t

Textile heading

\n\n\n\t" + - "

some text with styles

\n\n\n\t" + - "", - textile_and_markdown) - end - - def test_rdoc - @web.markup = :rdoc - - @revision = Revision.new(@page, 1, '+hello+ that SmartEngineGUI', - Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson') - - assert_equal "hello that Smart Engine GUI" + - "?\n\n", @revision.display_content - end - - def test_content_with_auto_links - assert_markup_parsed_as( - '

http://www.loudthinking.com/ ' + - 'points to That Way from ' + - 'david@loudthinking.com

', - 'http://www.loudthinking.com/ points to ThatWay from david@loudthinking.com') - - end - - def test_content_with_aliased_links - assert_markup_parsed_as( - '

Would a clever motor' + - ' go by any other name?

', - 'Would a [[SmartEngine|clever motor]] go by any other name?') - end - - def test_content_with_wikiword_in_em - assert_markup_parsed_as( - '

should we go ' + - 'That Way or This Way?' + - '

', - '_should we go ThatWay or ThisWay _') - end - - def test_content_with_wikiword_in_tag - assert_markup_parsed_as( - '

That is some Stylish Emphasis

', - 'That is some Stylish Emphasis') - end - - def test_content_with_escaped_wikiword - # there should be no wiki link - assert_markup_parsed_as('

WikiWord

', '\WikiWord') - end - - def test_content_with_pre_blocks - assert_markup_parsed_as( - '

A class SmartEngine end would not mark up

CodeBlocks

', - 'A class SmartEngine end would not mark up
CodeBlocks
') - end - - def test_content_with_autolink_in_parentheses - assert_markup_parsed_as( - '

The W3C body (' + - 'http://www.w3c.org) sets web standards

', - 'The W3C body (http://www.w3c.org) sets web standards') - end - - def test_content_with_link_in_parentheses - assert_markup_parsed_as( - '

(What is a wiki?)

', - '("What is a wiki?":http://wiki.org/wiki.cgi?WhatIsWiki)') - end - - def test_content_with_image_link - assert_markup_parsed_as( - '

This is a Textile image link.

', - 'This !http://hobix.com/sample.jpg! is a Textile image link.') - end - - def test_content_with_inlined_img_tag - assert_markup_parsed_as( - '

This is an inline image link.

', - 'This is an inline image link.') - assert_markup_parsed_as( - '

This is an inline image link.

', - 'This is an inline image link.') - end - - def test_nowiki_tag - assert_markup_parsed_as( - '

Do not mark up [[this text]] or http://www.thislink.com.

', - 'Do not mark up [[this text]] ' + - 'or http://www.thislink.com.') - end - - def test_multiline_nowiki_tag - assert_markup_parsed_as( - "

Do not mark \n up [[this text]] \nand http://this.url.com but markup " + - 'this?

', - "Do not mark \n up [[this text]] \n" + - "and http://this.url.com but markup [[this]]") - end - - def test_content_with_bracketted_wiki_word - @web.brackets_only = true - assert_markup_parsed_as( - '

This is a WikiWord and a tricky name ' + - 'Sperberg-McQueen?.

', - 'This is a WikiWord and a tricky name [[Sperberg-McQueen]].') - end - - def test_content_for_export - assert_equal '

His Way would be ' + - 'My Way in kinda ' + - 'That Way in ' + - 'His Way though ' + - 'My Way OverThere—see ' + - 'Smart Engine in that ' + - 'Smart Engine GUI

', - @revision.display_content_for_export - end - - def test_double_replacing - @revision.content = "VersionHistory\r\n\r\ncry VersionHistory" - assert_equal '

Version History' + - "?

\n\n\n\t

cry " + - 'Version History?' + - '

', - @revision.display_content - - @revision.clear_display_cache - - @revision.content = "f\r\nVersionHistory\r\n\r\ncry VersionHistory" - assert_equal "

f
Version History" + - "?

\n\n\n\t

cry " + - "Version History?" + - "

", - @revision.display_content - end - - def test_difficult_wiki_words - @revision.content = "[[It's just awesome GUI!]]" - assert_equal "

It's just awesome GUI!" + - "?

", - @revision.display_content - end - - def test_revisions_diff - - @page.revisions = [ - Revision.new(@page, 0, 'What a blue and lovely morning', - Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson'), - Revision.new(@page, 1, 'What a red and lovely morning today', - Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson') - ] - - assert_equal "

What a blue red " + - "and lovely morningmorning " + - "today

", @page.revisions.last.display_diff - end - - def test_link_to_file - assert_markup_parsed_as( - '

doc.pdf?

', - '[[doc.pdf:file]]') - end - - def test_link_to_pic - FileUtils.mkdir_p "#{RAILS_ROOT}/storage/test/wiki1" - FileUtils.rm(Dir["#{RAILS_ROOT}/storage/test/wiki1/*"]) - @wiki.file_yard(@web).upload_file('square.jpg', StringIO.new('')) - assert_markup_parsed_as( - '

Square

', - '[[square.jpg|Square:pic]]') - assert_markup_parsed_as( - '

square.jpg

', - '[[square.jpg:pic]]') - end - - def test_link_to_non_existant_pic - assert_markup_parsed_as( - '

NonExistant?' + - '

', - '[[NonExistant.jpg|NonExistant:pic]]') - assert_markup_parsed_as( - '

NonExistant.jpg?' + - '

', - '[[NonExistant.jpg:pic]]') - end - - def test_wiki_link_with_colon - assert_markup_parsed_as( - '

With:Colon?

', - '[[With:Colon]]') - end - - # TODO Remove the leading underscores from this test when upgrading to RedCloth 3.0.1; - # also add a test for the "Unhappy Face" problem (another interesting RedCloth bug) - def test_list_with_tildas - list_with_tildas = <<-EOL - * "a":~b - * c~ d - EOL - - assert_markup_parsed_as( - "", - list_with_tildas) - end - - def test_textile_image_in_mixed_wiki - @web.markup = :mixed - assert_markup_parsed_as( - "

\"\"\nss

", - "!http://google.com!\r\nss") - end - - - def assert_markup_parsed_as(expected_output, input) - revision = Revision.new(@page, 1, input, Time.local(2004, 4, 4, 16, 50), 'AnAuthor') - assert_equal expected_output, revision.display_content, 'Textile output not as expected' - end - -end diff --git a/test-old/unit/web_test.rb b/test-old/unit/web_test.rb deleted file mode 100755 index 4cd15411..00000000 --- a/test-old/unit/web_test.rb +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/env ruby -w - -require File.dirname(__FILE__) + '/../test_helper' -require 'wiki_service' - -class WebTest < Test::Unit::TestCase - def setup - @web = Web.new nil, 'Instiki', 'instiki' - end - - def test_wiki_word_linking - @web.add_page('SecondPage', 'Yo, yo. Have you EverBeenHated', - Time.now, 'DavidHeinemeierHansson') - - assert_equal('

Yo, yo. Have you Ever Been Hated' + - '?

', - @web.pages["SecondPage"].display_content) - - @web.add_page('EverBeenHated', 'Yo, yo. Have you EverBeenHated', Time.now, - 'DavidHeinemeierHansson') - assert_equal('

Yo, yo. Have you Ever Been Hated

', - @web.pages['SecondPage'].display_content) - end - - def test_pages_by_revision - add_sample_pages - assert_equal 'EverBeenHated', @web.select.by_revision.first.name - end - - def test_pages_by_match - add_sample_pages - assert_equal 2, @web.select { |page| page.content =~ /me/i }.length - assert_equal 1, @web.select { |page| page.content =~ /Who/i }.length - assert_equal 0, @web.select { |page| page.content =~ /none/i }.length - end - - def test_references - add_sample_pages - assert_equal 1, @web.select.pages_that_reference('EverBeenHated').length - assert_equal 0, @web.select.pages_that_reference('EverBeenInLove').length - end - - def test_delete - add_sample_pages - assert_equal 2, @web.pages.length - @web.remove_pages([ @web.pages['EverBeenInLove'] ]) - assert_equal 1, @web.pages.length - end - - def test_make_link - add_sample_pages - - existing_page_wiki_url = - 'Ever Been In Love' - existing_page_published_url = - 'Ever Been In Love' - existing_page_static_url = - 'Ever Been In Love' - new_page_wiki_url = - 'Unknown Word?' - new_page_published_url = - new_page_static_url = - 'Unknown Word' - - # no options - assert_equal existing_page_wiki_url, @web.make_link('EverBeenInLove') - - # :mode => :export - assert_equal existing_page_static_url, @web.make_link('EverBeenInLove', nil, :mode => :export) - - # :mode => :publish - assert_equal existing_page_published_url, - @web.make_link('EverBeenInLove', nil, :mode => :publish) - - # new page, no options - assert_equal new_page_wiki_url, @web.make_link('UnknownWord') - - # new page, :mode => :export - assert_equal new_page_static_url, @web.make_link('UnknownWord', nil, :mode => :export) - - # new page, :mode => :publish - assert_equal new_page_published_url, @web.make_link('UnknownWord', nil, :mode => :publish) - - # Escaping special characters in the name - assert_equal( - 'Smith & Wesson?', - @web.make_link('Smith & Wesson')) - - # optionally using text as the link text - assert_equal( - existing_page_published_url.sub(/>Ever Been In LoveHaven't you ever been in love?<"), - @web.make_link('EverBeenInLove', "Haven't you ever been in love?", :mode => :publish)) - - end - - def test_initialize - wiki_stub = Object.new - - web = Web.new(wiki_stub, 'Wiki2', 'wiki2', '123') - - assert_equal wiki_stub, web.wiki - assert_equal 'Wiki2', web.name - assert_equal 'wiki2', web.address - assert_equal '123', web.password - - # new web should be set for maximum features enabled - assert_equal :textile, web.markup - assert_equal '008B26', web.color - assert !web.safe_mode - assert_equal({}, web.pages) - assert web.allow_uploads - assert_equal wiki_stub, web.wiki - assert_nil web.additional_style - assert !web.published - assert !web.brackets_only - assert !web.count_pages - assert web.allow_uploads - assert_equal 100, web.max_upload_size - end - - def test_initialize_invalid_name - wiki_stub = Object.new - assert_raises(Instiki::ValidationError) { - Web.new(wiki_stub, 'Wiki2', "wiki\234", '123') - } - end - - def test_new_page_linked_from_mother_page - # this was a bug in revision 204 - home = @web.add_page('HomePage', 'This page refers to AnotherPage', - Time.local(2004, 4, 4, 16, 50), 'Alexey Verkhovsky') - @web.add_page('AnotherPage', 'This is \AnotherPage', - Time.local(2004, 4, 4, 16, 51), 'Alexey Verkhovsky') - - assert_equal [home], @web.select.pages_that_link_to('AnotherPage') - end - - def test_orphaned_pages - add_sample_pages - home = @web.add_page('HomePage', - 'This is a home page, it should not be an orphan', - Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky') - author = @web.add_page('AlexeyVerkhovsky', - 'This is an author page, it should not be an orphan', - Time.local(2004, 4, 4, 16, 50), 'AlexeyVerkhovsky') - self_linked = @web.add_page('SelfLinked', - 'I am me SelfLinked and link to EverBeenInLove', - Time.local(2004, 4, 4, 16, 50), 'AnonymousCoward') - - # page that links to itself, and nobody else links to it must be an orphan - assert_equal ['EverBeenHated', 'SelfLinked'], - @web.select.orphaned_pages.collect{ |page| page.name }.sort - end - - - private - - def add_sample_pages - @in_love = @web.add_page('EverBeenInLove', 'Who am I me', - Time.local(2004, 4, 4, 16, 50), 'DavidHeinemeierHansson') - @hated = @web.add_page('EverBeenHated', 'I am me EverBeenHated', - Time.local(2004, 4, 4, 16, 51), 'DavidHeinemeierHansson') - end -end diff --git a/test-old/unit/wiki_service_test.rb b/test-old/unit/wiki_service_test.rb deleted file mode 100755 index c02c61ff..00000000 --- a/test-old/unit/wiki_service_test.rb +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/env ruby -w - -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']) - FileUtils.rm(Dir[RAILS_ROOT + '/storage/test/instiki/*']) - @@cleaned_storage = true - WikiService.instance.setup('pswd', 'Wiki', 'wiki') - end - - def setup - @s = WikiService.instance - @s.create_web 'Instiki', 'instiki' - @web = @s.webs['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' - assert_equal "Electric shocks, I love 'em", @s.read_page('instiki', 'FirstPage').content - end - - def test_read_only_operations - @s.write_page 'instiki', 'TestReadOnlyOperations', 'Read only operations dont change the' + - 'state of any object, and therefore should not be logged by Madeleine!', - Time.now, 'AlexeyVerkhovsky' - - assert_doesnt_change_state_or_log :authenticate, 'pswd' - assert_doesnt_change_state_or_log :read_page, 'instiki', 'TestReadOnlyOperations' - assert_doesnt_change_state_or_log :setup? - assert_doesnt_change_state_or_log :webs - - @s.write_page 'instiki', 'FirstPage', "Electric shocks, I love 'em", - Time.now, 'DavidHeinemeierHansson' - assert_equal "Electric shocks, I love 'em", @s.read_page('instiki', 'FirstPage').content - end - - def test_aborted_transaction - @s.write_page 'instiki', 'FirstPage', "Electric shocks, I love 'em", - 10.minutes.ago, 'DavidHeinemeierHansson' - - assert_doesnt_change_state('revise_page with unchanged content') { - begin - @s.revise_page 'instiki', 'FirstPage', "Electric shocks, I love 'em", - Time.now, 'DavidHeinemeierHansson' - fail 'Expected Instiki::ValidationError not raised' - rescue Instiki::ValidationError - end - } - end - - def test_file_yard - file_yard = @s.file_yard(@web) - assert_equal FileYard, file_yard.class - assert_equal(@s.storage_path + '/instiki', file_yard.files_path) - end - - def test_edit_web_validations - another_web = @s.create_web 'Another', 'another' - - # try to rename instiki web to another (which is the name of an already existing one) - assert_raises(Instiki::ValidationError) { - @s.edit_web('instiki', 'another', @web.name, @web.markup, @web.color, @web.additional_style) - } - - assert_raises(Instiki::ValidationError) { - @s.edit_web('nonexistant', 'another', @web.name, @web.markup, @web.color, @web.additional_style) - } - end - - - # Checks that a method call or a block doesn;t change the persisted state of the wiki - # Usage: - # assert_doesnt_change_state :read_page, 'instiki', 'TestReadOnlyOperations' - # or - # assert_doesnt_change_state {|wiki| wiki.webs} - - def assert_doesnt_change_state(method, *args, &block) - _assert_doesnt_change_state(including_command_log = false, method, *args, &block) - end - - # Same as assert_doesnt_change_state, but also asserts that no vommand log is generated - def assert_doesnt_change_state_or_log(method, *args, &block) - _assert_doesnt_change_state(including_command_log = true, method, *args, &block) - end - - private - - def _assert_doesnt_change_state(including_log, method, *args) - WikiService.snapshot - last_snapshot_before = last_snapshot - - if block_given? - yield @s - else - @s.send(method, *args) - end - - if including_log - command_logs = Dir[RAILS_ROOT + 'storage/test/*.command_log'] - assert command_logs.empty?, "Calls to #{method} should not be logged" - end - - last_snapshot_after = last_snapshot - assert last_snapshot_before == last_snapshot_after, - 'Calls to #{method} should not change the state of any persisted object' - end - - def last_snapshot - snapshots = Dir[RAILS_ROOT + '/storage/test/*.snapshot'] - assert !snapshots.empty?, "No snapshots found at #{RAILS_ROOT}/storage/test/" - File.read(snapshots.last) - end - -end diff --git a/test-old/fixtures/rails.gif b/test/fixtures/rails.gif similarity index 100% rename from test-old/fixtures/rails.gif rename to test/fixtures/rails.gif diff --git a/test-old/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb similarity index 100% rename from test-old/functional/admin_controller_test.rb rename to test/functional/admin_controller_test.rb diff --git a/test-old/functional/application_test.rb b/test/functional/application_test.rb similarity index 100% rename from test-old/functional/application_test.rb rename to test/functional/application_test.rb diff --git a/test-old/functional/file_controller_test.rb b/test/functional/file_controller_test.rb similarity index 100% rename from test-old/functional/file_controller_test.rb rename to test/functional/file_controller_test.rb diff --git a/test/routes_test.rb b/test/functional/routes_test.rb similarity index 100% rename from test/routes_test.rb rename to test/functional/routes_test.rb diff --git a/test-old/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb similarity index 100% rename from test-old/functional/wiki_controller_test.rb rename to test/functional/wiki_controller_test.rb diff --git a/test-old/watir/e2e.rb b/test/watir/e2e.rb similarity index 100% rename from test-old/watir/e2e.rb rename to test/watir/e2e.rb