Added Redmine::WikiFormatting module and tests for wiki links.

RedCloth librairy is now present in Redmine lib directory.

git-svn-id: http://redmine.rubyforge.org/svn/trunk@699 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2007-09-02 20:41:47 +00:00
parent 324b904ed5
commit 8a3e713f2f
8 changed files with 1346 additions and 37 deletions
+35
View File
@@ -0,0 +1,35 @@
# Re-raise errors caught by the controller.
class StubController < ApplicationController
def rescue_action(e) raise e end;
attr_accessor :request, :url
end
class HelperTestCase < Test::Unit::TestCase
# Add other helpers here if you need them
include ActionView::Helpers::ActiveRecordHelper
include ActionView::Helpers::TagHelper
include ActionView::Helpers::FormTagHelper
include ActionView::Helpers::FormOptionsHelper
include ActionView::Helpers::FormHelper
include ActionView::Helpers::UrlHelper
include ActionView::Helpers::AssetTagHelper
include ActionView::Helpers::PrototypeHelper
def setup
super
@request = ActionController::TestRequest.new
@controller = StubController.new
@controller.request = @request
# Fake url rewriter so we can test url_for
@controller.url = ActionController::UrlRewriter.new @request, {}
ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
end
def test_dummy
# do nothing - required by test/unit
end
end
+1
View File
@@ -18,6 +18,7 @@
ENV["RAILS_ENV"] ||= "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require File.expand_path(File.dirname(__FILE__) + '/helper_testcase')
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
@@ -0,0 +1,66 @@
# 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 ApplicationHelperTest < HelperTestCase
include ApplicationHelper
fixtures :projects
def setup
super
end
def test_auto_links
to_test = {
'http://foo.bar' => '<a href="http://foo.bar">http://foo.bar</a>',
'www.foo.bar' => '<a href="http://www.foo.bar">www.foo.bar</a>',
'http://foo.bar/page?p=1&t=z&s=' => '<a href="http://foo.bar/page?p=1&#38;t=z&#38;s=">http://foo.bar/page?p=1&#38;t=z&#38;s=</a>',
'http://foo.bar/page#125' => '<a href="http://foo.bar/page#125">http://foo.bar/page#125</a>'
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
def test_auto_mailto
assert_equal '<p><a href="mailto:test@foo.bar" class="email">test@foo.bar</a></p>',
textilizable('test@foo.bar')
end
def test_textile_tags
to_test = {
# inline images
'!http://foo.bar/image.jpg!' => '<img src="http://foo.bar/image.jpg" alt="" />',
'floating !>http://foo.bar/image.jpg!' => 'floating <div style="float:right"><img src="http://foo.bar/image.jpg" alt="" /></div>',
# textile links
'This is a "link":http://foo.bar' => 'This is a <a href="http://foo.bar">link</a>',
'"link (Link title)":http://foo.bar' => '<a href="http://foo.bar" title="Link title">link</a>'
}
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
def test_redmine_links
issue_link = link_to('#52', {:controller => 'issues', :action => 'show', :id => 52}, :class => 'issue')
changeset_link = link_to('r19', {:controller => 'repositories', :action => 'revision', :id => 1, :rev => 19}, :class => 'changeset')
to_test = {
'#52, #52 and #52.' => "#{issue_link}, #{issue_link} and #{issue_link}.",
'r19' => changeset_link
}
@project = Project.find(1)
to_test.each { |text, result| assert_equal "<p>#{result}</p>", textilizable(text) }
end
end
+1 -1
View File
@@ -20,7 +20,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class SettingTest < Test::Unit::TestCase
def test_read_default
assert_equal "redMine", Setting.app_title
assert_equal "Redmine", Setting.app_title
assert Setting.self_registration?
assert !Setting.login_required?
end