annotate test/unit/lib/redmine/wiki_formatting/macros_test.rb @ 36:de76cd3e8c8e cc-branches

* Probably abortive experiments in extracting the branch from Hg
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 20 Oct 2010 10:07:29 +0100
parents 513646585e45
children 94944d00e43c
rev   line source
Chris@0 1 # Redmine - project management software
Chris@0 2 # Copyright (C) 2006-2008 Jean-Philippe Lang
Chris@0 3 #
Chris@0 4 # This program is free software; you can redistribute it and/or
Chris@0 5 # modify it under the terms of the GNU General Public License
Chris@0 6 # as published by the Free Software Foundation; either version 2
Chris@0 7 # of the License, or (at your option) any later version.
Chris@0 8 #
Chris@0 9 # This program is distributed in the hope that it will be useful,
Chris@0 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@0 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@0 12 # GNU General Public License for more details.
Chris@0 13 #
Chris@0 14 # You should have received a copy of the GNU General Public License
Chris@0 15 # along with this program; if not, write to the Free Software
Chris@0 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@0 17
Chris@0 18 require File.dirname(__FILE__) + '/../../../../test_helper'
Chris@0 19
Chris@0 20 class Redmine::WikiFormatting::MacrosTest < HelperTestCase
Chris@0 21 include ApplicationHelper
Chris@0 22 include ActionView::Helpers::TextHelper
Chris@0 23 fixtures :projects, :roles, :enabled_modules, :users,
Chris@0 24 :repositories, :changesets,
Chris@0 25 :trackers, :issue_statuses, :issues,
Chris@0 26 :versions, :documents,
Chris@0 27 :wikis, :wiki_pages, :wiki_contents,
Chris@0 28 :boards, :messages,
Chris@0 29 :attachments
Chris@0 30
Chris@0 31 def setup
Chris@0 32 super
Chris@0 33 @project = nil
Chris@0 34 end
Chris@0 35
Chris@0 36 def teardown
Chris@0 37 end
Chris@0 38
Chris@0 39 def test_macro_hello_world
Chris@0 40 text = "{{hello_world}}"
Chris@0 41 assert textilizable(text).match(/Hello world!/)
Chris@0 42 # escaping
Chris@0 43 text = "!{{hello_world}}"
Chris@0 44 assert_equal '<p>{{hello_world}}</p>', textilizable(text)
Chris@0 45 end
Chris@0 46
Chris@0 47 def test_macro_include
Chris@0 48 @project = Project.find(1)
Chris@0 49 # include a page of the current project wiki
Chris@0 50 text = "{{include(Another page)}}"
Chris@0 51 assert textilizable(text).match(/This is a link to a ticket/)
Chris@0 52
Chris@0 53 @project = nil
Chris@0 54 # include a page of a specific project wiki
Chris@0 55 text = "{{include(ecookbook:Another page)}}"
Chris@0 56 assert textilizable(text).match(/This is a link to a ticket/)
Chris@0 57
Chris@0 58 text = "{{include(ecookbook:)}}"
Chris@0 59 assert textilizable(text).match(/CookBook documentation/)
Chris@0 60
Chris@0 61 text = "{{include(unknowidentifier:somepage)}}"
Chris@0 62 assert textilizable(text).match(/Page not found/)
Chris@0 63 end
Chris@0 64
Chris@0 65 def test_macro_child_pages
Chris@0 66 expected = "<p><ul class=\"pages-hierarchy\">\n" +
Chris@0 67 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
Chris@0 68 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
Chris@0 69 "</ul>\n</p>"
Chris@0 70
Chris@0 71 @project = Project.find(1)
Chris@0 72 # child pages of the current wiki page
Chris@0 73 assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content)
Chris@0 74 # child pages of another page
Chris@0 75 assert_equal expected, textilizable("{{child_pages(Another_page)}}", :object => WikiPage.find(1).content)
Chris@0 76
Chris@0 77 @project = Project.find(2)
Chris@0 78 assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page)}}", :object => WikiPage.find(1).content)
Chris@0 79 end
Chris@0 80
Chris@0 81 def test_macro_child_pages_with_option
Chris@0 82 expected = "<p><ul class=\"pages-hierarchy\">\n" +
Chris@0 83 "<li><a href=\"/projects/ecookbook/wiki/Another_page\">Another page</a>\n" +
Chris@0 84 "<ul class=\"pages-hierarchy\">\n" +
Chris@0 85 "<li><a href=\"/projects/ecookbook/wiki/Child_1\">Child 1</a></li>\n" +
Chris@0 86 "<li><a href=\"/projects/ecookbook/wiki/Child_2\">Child 2</a></li>\n" +
Chris@0 87 "</ul>\n</li>\n</ul>\n</p>"
Chris@0 88
Chris@0 89 @project = Project.find(1)
Chris@0 90 # child pages of the current wiki page
Chris@0 91 assert_equal expected, textilizable("{{child_pages(parent=1)}}", :object => WikiPage.find(2).content)
Chris@0 92 # child pages of another page
Chris@0 93 assert_equal expected, textilizable("{{child_pages(Another_page, parent=1)}}", :object => WikiPage.find(1).content)
Chris@0 94
Chris@0 95 @project = Project.find(2)
Chris@0 96 assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page, parent=1)}}", :object => WikiPage.find(1).content)
Chris@0 97 end
Chris@0 98 end