summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGo MAEDA <maeda@farend.jp>2019-05-04 09:32:05 +0000
committerGo MAEDA <maeda@farend.jp>2019-05-04 09:32:05 +0000
commit400e1ca2ffffa9f2d4383e30c8c2c0e0b02c964b (patch)
tree1340bca4491732e86abb8f22039c1673292f6945 /test
parentcff50a591533bcc66588baaa555bb2790cc6d9fc (diff)
downloadredmine-400e1ca2ffffa9f2d4383e30c8c2c0e0b02c964b.tar.gz
redmine-400e1ca2ffffa9f2d4383e30c8c2c0e0b02c964b.zip
Attachment preview does not work for some source files such as JavaScript and Go (#29259).
Patch by Go MAEDA with the help of Stephan Wenzel's contribution. git-svn-id: http://svn.redmine.org/redmine/trunk@18122 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test')
-rw-r--r--test/fixtures/files/hello.js1
-rw-r--r--test/unit/attachment_test.rb17
-rw-r--r--test/unit/lib/redmine/syntax_highlighting/rouge_test.rb12
3 files changed, 30 insertions, 0 deletions
diff --git a/test/fixtures/files/hello.js b/test/fixtures/files/hello.js
new file mode 100644
index 000000000..c0380dc44
--- /dev/null
+++ b/test/fixtures/files/hello.js
@@ -0,0 +1 @@
+document.write('Hello, World!');
diff --git a/test/unit/attachment_test.rb b/test/unit/attachment_test.rb
index 1ed1a719e..384ee1fd7 100644
--- a/test/unit/attachment_test.rb
+++ b/test/unit/attachment_test.rb
@@ -502,4 +502,21 @@ class AttachmentTest < ActiveSupport::TestCase
puts '(ImageMagick convert not available)'
end
+ def test_is_text
+ js_attachment = Attachment.new(
+ :container => Issue.find(1),
+ :file => uploaded_test_file('hello.js', 'application/javascript'),
+ :author => User.find(1))
+
+ to_test = {
+ js_attachment => true, # hello.js (application/javascript)
+ attachments(:attachments_003) => false, # logo.gif (image/gif)
+ attachments(:attachments_004) => true, # source.rb (application/x-ruby)
+ attachments(:attachments_015) => true, # private.diff (text/x-diff)
+ attachments(:attachments_016) => false, # testfile.png (image/png)
+ }
+ to_test.each do |attachment, expected|
+ assert_equal expected, attachment.is_text?, attachment.inspect
+ end
+ end
end
diff --git a/test/unit/lib/redmine/syntax_highlighting/rouge_test.rb b/test/unit/lib/redmine/syntax_highlighting/rouge_test.rb
index 0bee260e1..862c3afca 100644
--- a/test/unit/lib/redmine/syntax_highlighting/rouge_test.rb
+++ b/test/unit/lib/redmine/syntax_highlighting/rouge_test.rb
@@ -20,6 +20,18 @@
require File.expand_path('../../../../../test_helper', __FILE__)
class Redmine::SyntaxHighlighting::RougeTest < ActiveSupport::TestCase
+ def test_filename_supported
+ to_test = {
+ 'application.js' => true,
+ 'Gemfile' => true,
+ 'AUTOEXEC.BAT' => false, # Rouge does not support BAT files
+ 'HELLO.C' => true
+ }
+ to_test.each do |filename, expected|
+ assert_equal expected, Redmine::SyntaxHighlighting::Rouge.filename_supported?(filename)
+ end
+ end
+
def test_highlight_by_filename_should_distinguish_perl_and_prolog
raw_perl = <<'RAW_PERL'
#!/usr/bin/perl