#-- encoding: UTF-8 #-- copyright # OpenProject is a project management system. # # Copyright (C) 2012-2013 the OpenProject Team # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License version 3. # # See doc/COPYRIGHT.rdoc for more details. #++ require File.expand_path('../../../../../test_helper', __FILE__) class Redmine::WikiFormatting::MacrosTest < HelperTestCase include ApplicationHelper include WorkPackagesHelper include ActionView::Helpers::TextHelper include ActionView::Helpers::SanitizeHelper extend ActionView::Helpers::SanitizeHelper::ClassMethods fixtures :all def setup super @project = nil end def teardown end def test_macro_hello_world text = "{{hello_world}}" assert textilizable(text).match(/Hello world!/) # escaping text = "!{{hello_world}}" assert_equal '
{{hello_world}}
', textilizable(text) end def test_macro_include @project = Project.find(1) # include a page of the current project wiki text = "{{include(Another page)}}" assert textilizable(text).match(/This is a link to a ticket/) @project = nil # include a page of a specific project wiki text = "{{include(ecookbook:Another page)}}" assert textilizable(text).match(/This is a link to a ticket/) text = "{{include(ecookbook:)}}" assert textilizable(text).match(/CookBook documentation/) text = "{{include(unknowidentifier:somepage)}}" assert textilizable(text).match(/Page not found/) end def test_macro_child_pages expected = "\n" @project = Project.find(1) # child pages of the current wiki page assert_equal expected, textilizable("{{child_pages}}", :object => WikiPage.find(2).content) # child pages of another page assert_equal expected, textilizable("{{child_pages(Another_page)}}", :object => WikiPage.find(1).content) @project = Project.find(2) assert_equal expected, textilizable("{{child_pages(ecookbook:Another_page)}}", :object => WikiPage.find(1).content) end def test_macro_child_pages_with_option expected = "