annotate .svn/pristine/39/390e71b002ea8073c16b9d8e33ea8c3450b2266a.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents cbb26bc654de
children
rev   line source
Chris@909 1 # Redmine - project management software
Chris@909 2 # Copyright (C) 2006-2011 Jean-Philippe Lang
Chris@909 3 #
Chris@909 4 # This program is free software; you can redistribute it and/or
Chris@909 5 # modify it under the terms of the GNU General Public License
Chris@909 6 # as published by the Free Software Foundation; either version 2
Chris@909 7 # of the License, or (at your option) any later version.
Chris@909 8 #
Chris@909 9 # This program is distributed in the hope that it will be useful,
Chris@909 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@909 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@909 12 # GNU General Public License for more details.
Chris@909 13 #
Chris@909 14 # You should have received a copy of the GNU General Public License
Chris@909 15 # along with this program; if not, write to the Free Software
Chris@909 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@909 17
Chris@909 18 require File.expand_path('../../../../test_helper', __FILE__)
Chris@909 19
Chris@909 20 class Redmine::PluginTest < ActiveSupport::TestCase
Chris@909 21
Chris@909 22 def setup
Chris@909 23 @klass = Redmine::Plugin
Chris@909 24 # In case some real plugins are installed
Chris@909 25 @klass.clear
Chris@909 26 end
Chris@909 27
Chris@909 28 def teardown
Chris@909 29 @klass.clear
Chris@909 30 end
Chris@909 31
Chris@909 32 def test_register
Chris@909 33 @klass.register :foo do
Chris@909 34 name 'Foo plugin'
Chris@909 35 url 'http://example.net/plugins/foo'
Chris@909 36 author 'John Smith'
Chris@909 37 author_url 'http://example.net/jsmith'
Chris@909 38 description 'This is a test plugin'
Chris@909 39 version '0.0.1'
Chris@909 40 settings :default => {'sample_setting' => 'value', 'foo'=>'bar'}, :partial => 'foo/settings'
Chris@909 41 end
Chris@909 42
Chris@909 43 assert_equal 1, @klass.all.size
Chris@909 44
Chris@909 45 plugin = @klass.find('foo')
Chris@909 46 assert plugin.is_a?(Redmine::Plugin)
Chris@909 47 assert_equal :foo, plugin.id
Chris@909 48 assert_equal 'Foo plugin', plugin.name
Chris@909 49 assert_equal 'http://example.net/plugins/foo', plugin.url
Chris@909 50 assert_equal 'John Smith', plugin.author
Chris@909 51 assert_equal 'http://example.net/jsmith', plugin.author_url
Chris@909 52 assert_equal 'This is a test plugin', plugin.description
Chris@909 53 assert_equal '0.0.1', plugin.version
Chris@909 54 end
Chris@909 55
Chris@909 56 def test_requires_redmine
Chris@909 57 test = self
Chris@909 58 version = Redmine::VERSION.to_a.slice(0,3).join('.')
Chris@909 59
Chris@909 60 @klass.register :foo do
Chris@909 61 test.assert requires_redmine(:version_or_higher => '0.1.0')
Chris@909 62 test.assert requires_redmine(:version_or_higher => version)
Chris@909 63 test.assert requires_redmine(version)
Chris@909 64 test.assert_raise Redmine::PluginRequirementError do
Chris@909 65 requires_redmine(:version_or_higher => '99.0.0')
Chris@909 66 end
Chris@909 67
Chris@909 68 test.assert requires_redmine(:version => version)
Chris@909 69 test.assert requires_redmine(:version => [version, '99.0.0'])
Chris@909 70 test.assert_raise Redmine::PluginRequirementError do
Chris@909 71 requires_redmine(:version => '99.0.0')
Chris@909 72 end
Chris@909 73 test.assert_raise Redmine::PluginRequirementError do
Chris@909 74 requires_redmine(:version => ['98.0.0', '99.0.0'])
Chris@909 75 end
Chris@909 76 end
Chris@909 77 end
Chris@909 78
Chris@909 79 def test_requires_redmine_plugin
Chris@909 80 test = self
Chris@909 81 other_version = '0.5.0'
Chris@909 82
Chris@909 83 @klass.register :other do
Chris@909 84 name 'Other'
Chris@909 85 version other_version
Chris@909 86 end
Chris@909 87
Chris@909 88 @klass.register :foo do
Chris@909 89 test.assert requires_redmine_plugin(:other, :version_or_higher => '0.1.0')
Chris@909 90 test.assert requires_redmine_plugin(:other, :version_or_higher => other_version)
Chris@909 91 test.assert requires_redmine_plugin(:other, other_version)
Chris@909 92 test.assert_raise Redmine::PluginRequirementError do
Chris@909 93 requires_redmine_plugin(:other, :version_or_higher => '99.0.0')
Chris@909 94 end
Chris@909 95
Chris@909 96 test.assert requires_redmine_plugin(:other, :version => other_version)
Chris@909 97 test.assert requires_redmine_plugin(:other, :version => [other_version, '99.0.0'])
Chris@909 98 test.assert_raise Redmine::PluginRequirementError do
Chris@909 99 requires_redmine_plugin(:other, :version => '99.0.0')
Chris@909 100 end
Chris@909 101 test.assert_raise Redmine::PluginRequirementError do
Chris@909 102 requires_redmine_plugin(:other, :version => ['98.0.0', '99.0.0'])
Chris@909 103 end
Chris@909 104 # Missing plugin
Chris@909 105 test.assert_raise Redmine::PluginNotFound do
Chris@909 106 requires_redmine_plugin(:missing, :version_or_higher => '0.1.0')
Chris@909 107 end
Chris@909 108 test.assert_raise Redmine::PluginNotFound do
Chris@909 109 requires_redmine_plugin(:missing, '0.1.0')
Chris@909 110 end
Chris@909 111 test.assert_raise Redmine::PluginNotFound do
Chris@909 112 requires_redmine_plugin(:missing, :version => '0.1.0')
Chris@909 113 end
Chris@909 114
Chris@909 115 end
Chris@909 116 end
Chris@909 117 end