Makes Plugin#requires_redmine accept only major and minor version (#12299).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10826 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2012-11-17 10:07:21 +00:00
parent 19bd857790
commit b3cf67cad4
2 changed files with 13 additions and 1 deletions

View File

@ -179,7 +179,7 @@ module Redmine #:nodoc:
raise PluginRequirementError.new("#{id} plugin requires Redmine #{v} or higher but current is #{current.join('.')}") raise PluginRequirementError.new("#{id} plugin requires Redmine #{v} or higher but current is #{current.join('.')}")
end end
when :version 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('.')}") raise PluginRequirementError.new("#{id} plugin requires one the following Redmine versions: #{v.join(', ')} but current is #{current.join('.')}")
end end
end end

View File

@ -88,24 +88,36 @@ class Redmine::PluginTest < ActiveSupport::TestCase
Redmine::VERSION.stubs(:to_a).returns([2, 1, 3, "stable", 10817]) Redmine::VERSION.stubs(:to_a).returns([2, 1, 3, "stable", 10817])
assert plugin.requires_redmine('2.1.3') assert plugin.requires_redmine('2.1.3')
assert plugin.requires_redmine('2.1')
assert_raise Redmine::PluginRequirementError do assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine('2.1.4') plugin.requires_redmine('2.1.4')
end 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 => '0.1.0')
assert plugin.requires_redmine(:version_or_higher => '2.1.3') assert plugin.requires_redmine(:version_or_higher => '2.1.3')
assert plugin.requires_redmine(:version_or_higher => '2.1')
assert_raise Redmine::PluginRequirementError do assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version_or_higher => '2.2.0') plugin.requires_redmine(:version_or_higher => '2.2.0')
end 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')
assert plugin.requires_redmine(:version => ['2.1.3', '2.2.0']) assert plugin.requires_redmine(:version => ['2.1.3', '2.2.0'])
assert plugin.requires_redmine(:version => '2.1')
assert_raise Redmine::PluginRequirementError do assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version => '2.2.0') plugin.requires_redmine(:version => '2.2.0')
end end
assert_raise Redmine::PluginRequirementError do assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version => ['2.1.4', '2.2.0']) plugin.requires_redmine(:version => ['2.1.4', '2.2.0'])
end end
assert_raise Redmine::PluginRequirementError do
plugin.requires_redmine(:version => '2.2')
end
end end
def test_requires_redmine_plugin def test_requires_redmine_plugin