Chris@909: # Redmine - project management software Chris@909: # Copyright (C) 2006-2011 Jean-Philippe Lang Chris@909: # Chris@909: # This program is free software; you can redistribute it and/or Chris@909: # modify it under the terms of the GNU General Public License Chris@909: # as published by the Free Software Foundation; either version 2 Chris@909: # of the License, or (at your option) any later version. Chris@909: # Chris@909: # This program is distributed in the hope that it will be useful, Chris@909: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@909: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@909: # GNU General Public License for more details. Chris@909: # Chris@909: # You should have received a copy of the GNU General Public License Chris@909: # along with this program; if not, write to the Free Software Chris@909: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@909: Chris@909: require File.expand_path('../../../../../test_helper', __FILE__) Chris@909: Chris@909: class Redmine::WikiFormatting::MacrosTest < ActionView::TestCase Chris@909: include ApplicationHelper Chris@909: include ActionView::Helpers::TextHelper Chris@909: include ActionView::Helpers::SanitizeHelper Chris@909: extend ActionView::Helpers::SanitizeHelper::ClassMethods Chris@909: Chris@909: fixtures :projects, :roles, :enabled_modules, :users, Chris@909: :repositories, :changesets, Chris@909: :trackers, :issue_statuses, :issues, Chris@909: :versions, :documents, Chris@909: :wikis, :wiki_pages, :wiki_contents, Chris@909: :boards, :messages, Chris@909: :attachments Chris@909: Chris@909: def setup Chris@909: super Chris@909: @project = nil Chris@909: end Chris@909: Chris@909: def teardown Chris@909: end Chris@909: Chris@909: def test_macro_hello_world Chris@909: text = "{{hello_world}}" Chris@909: assert textilizable(text).match(/Hello world!/) Chris@909: # escaping Chris@909: text = "!{{hello_world}}" Chris@909: assert_equal '
{{hello_world}}
', textilizable(text) Chris@909: end Chris@909: Chris@909: def test_macro_include Chris@909: @project = Project.find(1) Chris@909: # include a page of the current project wiki Chris@909: text = "{{include(Another page)}}" Chris@909: assert textilizable(text).match(/This is a link to a ticket/) Chris@909: Chris@909: @project = nil Chris@909: # include a page of a specific project wiki Chris@909: text = "{{include(ecookbook:Another page)}}" Chris@909: assert textilizable(text).match(/This is a link to a ticket/) Chris@909: Chris@909: text = "{{include(ecookbook:)}}" Chris@909: assert textilizable(text).match(/CookBook documentation/) Chris@909: Chris@909: text = "{{include(unknowidentifier:somepage)}}" Chris@909: assert textilizable(text).match(/Page not found/) Chris@909: end Chris@909: Chris@909: def test_macro_child_pages Chris@909: expected = "\n" Chris@909: Chris@909: @project = Project.find(1) Chris@909: # child pages of the current wiki page Chris@909: assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content) Chris@909: # child pages of another page Chris@909: assert_equal expected, textilizable("{{child_pages(Another_page)}}", :object => WikiPage.find(1).content) Chris@909: Chris@909: @project = Project.find(2) Chris@909: assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page)}}", :object => WikiPage.find(1).content) Chris@909: end Chris@909: Chris@909: def test_macro_child_pages_with_option Chris@909: expected = "