Chris@154: # Redmine - project management software Chris@154: # Copyright (C) 2008 Jean-Philippe Lang Chris@154: # Chris@154: # This program is free software; you can redistribute it and/or Chris@154: # modify it under the terms of the GNU General Public License Chris@154: # as published by the Free Software Foundation; either version 2 Chris@154: # of the License, or (at your option) any later version. Chris@154: # Chris@154: # This program is distributed in the hope that it will be useful, Chris@154: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@154: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@154: # GNU General Public License for more details. Chris@154: # Chris@154: # You should have received a copy of the GNU General Public License Chris@154: # along with this program; if not, write to the Free Software Chris@154: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@154: Chris@154: require File.dirname(__FILE__) + '/../test_helper' Chris@154: Chris@154: class EmbeddedTest < ActiveSupport::TestCase Chris@154: Chris@154: def setup Chris@154: Setting.plugin_embedded = { 'path' => '/path/to', Chris@154: 'index' => 'main.html overview-summary.html index.html', Chris@154: 'extensions' => 'html png gif', Chris@154: 'template' => 'doxygen', Chris@154: 'encoding' => '', Chris@154: 'menu' => 'Embedded' } Chris@154: end Chris@154: Chris@154: def test_available_templates Chris@154: assert_equal ['doxygen', 'javadoc', 'rcov'], Redmine::Plugins::Embedded.available_templates Chris@154: end Chris@154: Chris@154: def test_assets Chris@154: assert_equal ['rcov.css', 'rcov.js'], Redmine::Plugins::Embedded.assets('rcov') Chris@154: end Chris@154: Chris@154: def test_detect_template_from_path Chris@154: to_test = { '/path/to/doc' => 'doxygen', Chris@154: '/path/to/javadoc/html' => 'javadoc' } Chris@154: Chris@154: to_test.each { |path, template| assert_equal template, Redmine::Plugins::Embedded.detect_template_from_path(path) } Chris@154: end Chris@154: Chris@154: def test_valid_extension Chris@154: to_test = {'index.html' => true, Chris@154: 'path/to/index.html' => true, Chris@154: 'path/to/image.png' => true, Chris@154: 'path/to/something.else' => false} Chris@154: Chris@154: to_test.each { |path, expected| assert_equal expected, Redmine::Plugins::Embedded.valid_extension?(path) } Chris@154: end Chris@154: end