Chris@154
|
1 # Redmine - project management software
|
Chris@154
|
2 # Copyright (C) 2008 Jean-Philippe Lang
|
Chris@154
|
3 #
|
Chris@154
|
4 # This program is free software; you can redistribute it and/or
|
Chris@154
|
5 # modify it under the terms of the GNU General Public License
|
Chris@154
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@154
|
7 # of the License, or (at your option) any later version.
|
Chris@154
|
8 #
|
Chris@154
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@154
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@154
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@154
|
12 # GNU General Public License for more details.
|
Chris@154
|
13 #
|
Chris@154
|
14 # You should have received a copy of the GNU General Public License
|
Chris@154
|
15 # along with this program; if not, write to the Free Software
|
Chris@154
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@154
|
17
|
Chris@154
|
18 require File.dirname(__FILE__) + '/../test_helper'
|
Chris@154
|
19
|
Chris@154
|
20 class EmbeddedTest < ActiveSupport::TestCase
|
Chris@154
|
21
|
Chris@154
|
22 def setup
|
Chris@154
|
23 Setting.plugin_embedded = { 'path' => '/path/to',
|
Chris@154
|
24 'index' => 'main.html overview-summary.html index.html',
|
Chris@154
|
25 'extensions' => 'html png gif',
|
Chris@154
|
26 'template' => 'doxygen',
|
Chris@154
|
27 'encoding' => '',
|
Chris@154
|
28 'menu' => 'Embedded' }
|
Chris@154
|
29 end
|
Chris@154
|
30
|
Chris@154
|
31 def test_available_templates
|
Chris@154
|
32 assert_equal ['doxygen', 'javadoc', 'rcov'], Redmine::Plugins::Embedded.available_templates
|
Chris@154
|
33 end
|
Chris@154
|
34
|
Chris@154
|
35 def test_assets
|
Chris@154
|
36 assert_equal ['rcov.css', 'rcov.js'], Redmine::Plugins::Embedded.assets('rcov')
|
Chris@154
|
37 end
|
Chris@154
|
38
|
Chris@154
|
39 def test_detect_template_from_path
|
Chris@154
|
40 to_test = { '/path/to/doc' => 'doxygen',
|
Chris@154
|
41 '/path/to/javadoc/html' => 'javadoc' }
|
Chris@154
|
42
|
Chris@154
|
43 to_test.each { |path, template| assert_equal template, Redmine::Plugins::Embedded.detect_template_from_path(path) }
|
Chris@154
|
44 end
|
Chris@154
|
45
|
Chris@154
|
46 def test_valid_extension
|
Chris@154
|
47 to_test = {'index.html' => true,
|
Chris@154
|
48 'path/to/index.html' => true,
|
Chris@154
|
49 'path/to/image.png' => true,
|
Chris@154
|
50 'path/to/something.else' => false}
|
Chris@154
|
51
|
Chris@154
|
52 to_test.each { |path, expected| assert_equal expected, Redmine::Plugins::Embedded.valid_extension?(path) }
|
Chris@154
|
53 end
|
Chris@154
|
54 end
|