annotate .svn/pristine/45/456ef3443ff7df8c5dc761c97f3f05ad3eb5ac25.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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