summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2018-09-29 06:57:40 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2018-09-29 06:57:40 +0000
commiteb1e6d8c260e272fdee28ea1df5f034b2731215d (patch)
treefaa172085f3fee950a46cc092296fc6c23f2df6c /test
parentbd2ee802c067f4e4880958c10b442a699f509431 (diff)
downloadredmine-eb1e6d8c260e272fdee28ea1df5f034b2731215d.tar.gz
redmine-eb1e6d8c260e272fdee28ea1df5f034b2731215d.zip
Syntax highlighter: replace CodeRay with Rouge (#24681).
Patch by Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@17532 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/helpers/application_helper_test.rb24
-rw-r--r--test/unit/lib/redmine/syntax_highlighting/coderay_test.rb37
-rw-r--r--test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb2
-rw-r--r--test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb4
4 files changed, 23 insertions, 44 deletions
diff --git a/test/helpers/application_helper_test.rb b/test/helpers/application_helper_test.rb
index d4990d39f..5561e2f40 100644
--- a/test/helpers/application_helper_test.rb
+++ b/test/helpers/application_helper_test.rb
@@ -1094,19 +1094,35 @@ EXPECTED
def test_syntax_highlight
raw = <<-RAW
-<pre><code class="ruby">
-# Some ruby code here
+<pre><code class="ECMA_script">
+/* Hello */
+document.write("Hello World!");
</code></pre>
RAW
expected = <<-EXPECTED
-<pre><code class="ruby syntaxhl"><span class=\"CodeRay\"><span class="comment"># Some ruby code here</span></span>
-</code></pre>
+<pre><code class=\"ECMA_script syntaxhl\"><span class=\"cm\">/* Hello */</span><span class=\"nb\">document</span><span class=\"p\">.</span><span class=\"nx\">write</span><span class=\"p\">(</span><span class=\"s2\">\"Hello World!\"</span><span class=\"p\">);</span></code></pre>
EXPECTED
assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
end
+ def test_syntax_highlight_ampersand_in_textile
+ raw = <<-RAW
+<pre><code class="ruby">
+x = a & b
+</code></pre>
+RAW
+
+ expected = <<-EXPECTED
+<pre><code class=\"ruby syntaxhl\"><span class=\"n\">x</span> <span class=\"o\">=</span> <span class=\"n\">a</span> <span class=\"o\">&amp;</span> <span class=\"n\">b</span></code></pre>
+EXPECTED
+
+ with_settings :text_formatting => 'textile' do
+ assert_equal expected.gsub(%r{[\r\n\t]}, ''), textilizable(raw).gsub(%r{[\r\n\t]}, '')
+ end
+ end
+
def test_to_path_param
assert_equal 'test1/test2', to_path_param('test1/test2')
assert_equal 'test1/test2', to_path_param('/test1/test2/')
diff --git a/test/unit/lib/redmine/syntax_highlighting/coderay_test.rb b/test/unit/lib/redmine/syntax_highlighting/coderay_test.rb
deleted file mode 100644
index 1a2714b16..000000000
--- a/test/unit/lib/redmine/syntax_highlighting/coderay_test.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-# Redmine - project management software
-# Copyright (C) 2006-2017 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.expand_path('../../../../../test_helper', __FILE__)
-
-class Redmine::SyntaxHighlighting::CodeRayTest < ActiveSupport::TestCase
- def test_retrieve_supported_languages_should_return_array_of_symbols
- assert_kind_of Array, Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages)
- assert_kind_of Symbol, Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages).first
- end
-
- def test_retrieve_supported_languages_should_return_array_of_symbols_holding_languages
- assert_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :ruby
- end
-
- def test_retrieve_supported_languages_should_return_array_of_symbols_holding_languages_aliases
- assert_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :javascript
- end
-
- def test_retrieve_supported_languages_should_return_array_of_symbols_not_holding_internal_languages
- refute_includes Redmine::SyntaxHighlighting::CodeRay.send(:retrieve_supported_languages), :default
- end
-end
diff --git a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
index 07d17efa7..cfe8188f6 100644
--- a/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/markdown_formatter_test.rb
@@ -66,7 +66,7 @@ end
~~~
STR
assert_select_in @formatter.new(text).to_html, 'pre code.ruby.syntaxhl' do
- assert_select 'span.keyword', :text => 'def'
+ assert_select 'span.k', :text => 'def'
end
end
diff --git a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
index 712bc5000..cc31a4c80 100644
--- a/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
+++ b/test/unit/lib/redmine/wiki_formatting/textile_formatter_test.rb
@@ -547,9 +547,9 @@ STR
def test_should_allow_valid_language_class_attribute_on_code_tags
# language name is double-quoted
- assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
+ assert_html_output({"<code class=\"ruby\">test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"nb\">test</span></code>"}, false)
# language name is single-quoted
- assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"CodeRay\">test</span></code>"}, false)
+ assert_html_output({"<code class='ruby'>test</code>" => "<code class=\"ruby syntaxhl\"><span class=\"nb\">test</span></code>"}, false)
end
def test_should_not_allow_valid_language_class_attribute_on_non_code_offtags