summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/redmine/plugin.rb2
-rw-r--r--test/unit/lib/redmine/plugin_test.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/redmine/plugin.rb b/lib/redmine/plugin.rb
index 0b7a4f6e5..8bd961d4b 100644
--- a/lib/redmine/plugin.rb
+++ b/lib/redmine/plugin.rb
@@ -179,7 +179,7 @@ module Redmine #:nodoc:
raise PluginRequirementError.new("#{id} plugin requires Redmine #{v} or higher but current is #{current.join('.')}")
end
when :version
- unless versions.include?(current.slice(0,3))
+ unless versions.detect {|ver| current.slice(0, ver.size) == ver}
raise PluginRequirementError.new("#{id} plugin requires one the following Redmine versions: #{v.join(', ')} but current is #{current.join('.')}")
end
end
diff --git a/test/unit/lib/redmine/plugin_test.rb b/test/unit/lib/redmine/plugin_test.rb
index 2b0bcc074..c5fb0ff93 100644
--- a/test/unit/lib/redmine/plugin_test.rb
+++ b/test/unit/lib/redmine/plugin_test.rb
@@ -88,24 +88,36 @@ class Redmine::PluginTest < ActiveSupport::TestCase
Redmine::VERSION.stubs(:to_a).returns([2, 1, 3, "stable", 10817])
assert plugin.requires_redmine('2.1.3')
+ assert plugin.requires_redmine('2.1')
assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine('2.1.4')
end
+ assert_raise Redmine::PluginRequirementError do
+ plugin.requires_redmine('2.2')
+ end
assert plugin.requires_redmine(:version_or_higher => '0.1.0')
assert plugin.requires_redmine(:version_or_higher => '2.1.3')
+ assert plugin.requires_redmine(:version_or_higher => '2.1')
assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version_or_higher => '2.2.0')
end
+ assert_raise Redmine::PluginRequirementError do
+ plugin.requires_redmine(:version_or_higher => '2.2')
+ end
assert plugin.requires_redmine(:version => '2.1.3')
assert plugin.requires_redmine(:version => ['2.1.3', '2.2.0'])
+ assert plugin.requires_redmine(:version => '2.1')
assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version => '2.2.0')
end
assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version => ['2.1.4', '2.2.0'])
end
+ assert_raise Redmine::PluginRequirementError do
+ plugin.requires_redmine(:version => '2.2')
+ end
end
def test_requires_redmine_plugin