mirror of
https://github.com/meineerde/redmine.git
synced 2026-03-11 19:53:07 +00:00
added some unit tests for wiki
git-svn-id: http://redmine.rubyforge.org/svn/branches/work@311 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f34a8ad30e
commit
3e63fcf7ee
41
wiki/test/fixtures/wiki_content_versions.yml
vendored
Normal file
41
wiki/test/fixtures/wiki_content_versions.yml
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
wiki_content_versions_001:
|
||||
updated_on: 2007-03-07 00:08:07 +01:00
|
||||
page_id: 1
|
||||
id: 1
|
||||
version: 1
|
||||
author_id: 1
|
||||
comment: Page creation
|
||||
wiki_content_id: 1
|
||||
compression: ""
|
||||
data: |-
|
||||
h1. CookBook documentation
|
||||
|
||||
Some [[documentation]] here...
|
||||
wiki_content_versions_002:
|
||||
updated_on: 2007-03-07 00:08:34 +01:00
|
||||
page_id: 1
|
||||
id: 2
|
||||
version: 2
|
||||
author_id: 1
|
||||
comment: Small update
|
||||
wiki_content_id: 1
|
||||
compression: ""
|
||||
data: |-
|
||||
h1. CookBook documentation
|
||||
|
||||
Some updated [[documentation]] here...
|
||||
wiki_content_versions_003:
|
||||
updated_on: 2007-03-07 00:10:51 +01:00
|
||||
page_id: 1
|
||||
id: 3
|
||||
version: 3
|
||||
author_id: 1
|
||||
comment: Gzip compression activated
|
||||
wiki_content_id: 1
|
||||
compression: gzip
|
||||
data: !binary |
|
||||
H4sIAPv07UUAC8sw1FNwzs/PdgJihZT85NLc1LySxJLM/DxeLl6u4PzcVIXS
|
||||
gpTEktQUhehoFPnYWIWM1KJUhfLMkgyF9KrMggKgmozM4pL8okoAf/LnOFYA
|
||||
AAA=
|
||||
|
||||
17
wiki/test/fixtures/wiki_contents.yml
vendored
17
wiki/test/fixtures/wiki_contents.yml
vendored
@ -1,5 +1,12 @@
|
||||
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
|
||||
one:
|
||||
id: 1
|
||||
two:
|
||||
id: 2
|
||||
---
|
||||
wiki_contents_001:
|
||||
text: |-
|
||||
h1. CookBook documentation
|
||||
|
||||
Some updated [[documentation]] here with gzipped history
|
||||
updated_on: 2007-03-07 00:10:51 +01:00
|
||||
page_id: 1
|
||||
id: 1
|
||||
version: 3
|
||||
author_id: 1
|
||||
comment: Gzip compression activated
|
||||
|
||||
6
wiki/test/fixtures/wiki_pages.yml
vendored
Normal file
6
wiki/test/fixtures/wiki_pages.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
wiki_pages_001:
|
||||
created_on: 2007-03-07 00:08:07 +01:00
|
||||
title: CookBook_documentation
|
||||
id: 1
|
||||
wiki_id: 1
|
||||
6
wiki/test/fixtures/wikis.yml
vendored
Normal file
6
wiki/test/fixtures/wikis.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
wikis_001:
|
||||
status: 1
|
||||
start_page: CookBook documentation
|
||||
project_id: 1
|
||||
id: 1
|
||||
@ -1,10 +1,60 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class WikiContentTest < Test::Unit::TestCase
|
||||
fixtures :wiki_contents
|
||||
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :users
|
||||
|
||||
# Replace this with your real tests.
|
||||
def test_truth
|
||||
assert true
|
||||
def setup
|
||||
@wiki = Wiki.find(1)
|
||||
@page = @wiki.pages.first
|
||||
end
|
||||
|
||||
def test_create
|
||||
page = WikiPage.new(:wiki => @wiki, :title => "Page")
|
||||
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comment => "My comment")
|
||||
assert page.save
|
||||
page.reload
|
||||
|
||||
content = page.content
|
||||
assert_kind_of WikiContent, content
|
||||
assert_equal 1, content.version
|
||||
assert_equal 1, content.versions.length
|
||||
assert_equal "Content text", content.text
|
||||
assert_equal "My comment", content.comment
|
||||
assert_equal User.find(1), content.author
|
||||
assert_equal content.text, content.versions.last.text
|
||||
end
|
||||
|
||||
def test_update
|
||||
content = @page.content
|
||||
version_count = content.version
|
||||
content.text = "My new content"
|
||||
assert content.save
|
||||
content.reload
|
||||
assert_equal version_count+1, content.version
|
||||
assert_equal version_count+1, content.versions.length
|
||||
end
|
||||
|
||||
def test_fetch_history
|
||||
assert !@page.content.versions.empty?
|
||||
@page.content.versions.each do |version|
|
||||
assert_kind_of String, version.text
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
50
wiki/test/unit/wiki_page_test.rb
Normal file
50
wiki/test/unit/wiki_page_test.rb
Normal file
@ -0,0 +1,50 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class WikiPageTest < Test::Unit::TestCase
|
||||
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def setup
|
||||
@wiki = Wiki.find(1)
|
||||
@page = @wiki.pages.first
|
||||
end
|
||||
|
||||
def test_create
|
||||
page = WikiPage.new(:wiki => @wiki)
|
||||
assert !page.save
|
||||
assert_equal 1, page.errors.count
|
||||
|
||||
page.title = "Page"
|
||||
assert page.save
|
||||
page.reload
|
||||
|
||||
@wiki.reload
|
||||
assert @wiki.pages.include?(page)
|
||||
end
|
||||
|
||||
def test_find_or_new_page
|
||||
page = @wiki.find_or_new_page("CookBook documentation")
|
||||
assert_kind_of WikiPage, page
|
||||
assert !page.new_record?
|
||||
|
||||
page = @wiki.find_or_new_page("Non existing page")
|
||||
assert_kind_of WikiPage, page
|
||||
assert page.new_record?
|
||||
end
|
||||
end
|
||||
39
wiki/test/unit/wiki_test.rb
Normal file
39
wiki/test/unit/wiki_test.rb
Normal file
@ -0,0 +1,39 @@
|
||||
# redMine - project management software
|
||||
# Copyright (C) 2006-2007 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
require File.dirname(__FILE__) + '/../test_helper'
|
||||
|
||||
class WikiTest < Test::Unit::TestCase
|
||||
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions
|
||||
|
||||
def test_create
|
||||
wiki = Wiki.new(:project => Project.find(2))
|
||||
assert !wiki.save
|
||||
assert_equal 1, wiki.errors.count
|
||||
|
||||
wiki.start_page = "Start page"
|
||||
assert wiki.save
|
||||
end
|
||||
|
||||
def test_update
|
||||
@wiki = Wiki.find(1)
|
||||
@wiki.start_page = "Another start page"
|
||||
assert @wiki.save
|
||||
@wiki.reload
|
||||
assert_equal "Another start page", @wiki.start_page
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user