kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
127 lines
4.3 KiB
127 lines
4.3 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
16 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
16 years ago
|
|
||
11 years ago
|
describe Redmine::Plugin do
|
||
|
before do
|
||
16 years ago
|
@klass = Redmine::Plugin
|
||
|
# In case some real plugins are installed
|
||
|
@klass.clear
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
after do
|
||
16 years ago
|
@klass.clear
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should register' do
|
||
16 years ago
|
@klass.register :foo do
|
||
|
name 'Foo plugin'
|
||
16 years ago
|
url 'http://example.net/plugins/foo'
|
||
16 years ago
|
author 'John Smith'
|
||
16 years ago
|
author_url 'http://example.net/jsmith'
|
||
16 years ago
|
description 'This is a test plugin'
|
||
|
version '0.0.1'
|
||
10 years ago
|
settings default: { 'sample_setting' => 'value', 'foo' => 'bar' }, partial: 'foo/settings'
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
16 years ago
|
assert_equal 1, @klass.all.size
|
||
14 years ago
|
|
||
16 years ago
|
plugin = @klass.find('foo')
|
||
|
assert plugin.is_a?(Redmine::Plugin)
|
||
|
assert_equal :foo, plugin.id
|
||
|
assert_equal 'Foo plugin', plugin.name
|
||
16 years ago
|
assert_equal 'http://example.net/plugins/foo', plugin.url
|
||
16 years ago
|
assert_equal 'John Smith', plugin.author
|
||
16 years ago
|
assert_equal 'http://example.net/jsmith', plugin.author_url
|
||
16 years ago
|
assert_equal 'This is a test plugin', plugin.description
|
||
|
assert_equal '0.0.1', plugin.version
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should requires openproject' do
|
||
14 years ago
|
test = self
|
||
|
version = Redmine::VERSION.to_semver
|
||
|
|
||
|
@klass.register :foo do
|
||
12 years ago
|
test.assert requires_openproject('>= 0.1')
|
||
|
test.assert requires_openproject(">= #{version}")
|
||
|
test.assert requires_openproject(version)
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
12 years ago
|
requires_openproject('>= 99.0.0')
|
||
14 years ago
|
end
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
12 years ago
|
requires_openproject('< 0.9')
|
||
14 years ago
|
end
|
||
10 years ago
|
requires_openproject('> 0.9', '<= 99.0.0')
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
10 years ago
|
requires_openproject('< 0.9', '>= 98.0.0')
|
||
14 years ago
|
end
|
||
|
|
||
11 years ago
|
test.assert requires_openproject("~> #{Redmine::VERSION.to_semver.gsub(/\d+\z/, '0')}")
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
11 years ago
|
it 'should requires redmine plugin' do
|
||
15 years ago
|
test = self
|
||
|
other_version = '0.5.0'
|
||
14 years ago
|
|
||
15 years ago
|
@klass.register :other do
|
||
|
name 'Other'
|
||
|
version other_version
|
||
|
end
|
||
14 years ago
|
|
||
15 years ago
|
@klass.register :foo do
|
||
10 years ago
|
test.assert requires_redmine_plugin(:other, version_or_higher: '0.1.0')
|
||
|
test.assert requires_redmine_plugin(:other, version_or_higher: other_version)
|
||
15 years ago
|
test.assert requires_redmine_plugin(:other, other_version)
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
10 years ago
|
requires_redmine_plugin(:other, version_or_higher: '99.0.0')
|
||
15 years ago
|
end
|
||
14 years ago
|
|
||
10 years ago
|
test.assert requires_redmine_plugin(:other, version: other_version)
|
||
|
test.assert requires_redmine_plugin(:other, version: [other_version, '99.0.0'])
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
10 years ago
|
requires_redmine_plugin(:other, version: '99.0.0')
|
||
15 years ago
|
end
|
||
9 years ago
|
test.assert_raises Redmine::PluginRequirementError do
|
||
10 years ago
|
requires_redmine_plugin(:other, version: ['98.0.0', '99.0.0'])
|
||
15 years ago
|
end
|
||
|
# Missing plugin
|
||
9 years ago
|
test.assert_raises Redmine::PluginNotFound do
|
||
10 years ago
|
requires_redmine_plugin(:missing, version_or_higher: '0.1.0')
|
||
15 years ago
|
end
|
||
9 years ago
|
test.assert_raises Redmine::PluginNotFound do
|
||
15 years ago
|
requires_redmine_plugin(:missing, '0.1.0')
|
||
|
end
|
||
9 years ago
|
test.assert_raises Redmine::PluginNotFound do
|
||
10 years ago
|
requires_redmine_plugin(:missing, version: '0.1.0')
|
||
15 years ago
|
end
|
||
|
end
|
||
|
end
|
||
16 years ago
|
end
|