Skip to content
This repository was archived by the owner on Feb 14, 2019. It is now read-only.

Commit b954038

Browse files
committed
Fix tests
1 parent 5078d82 commit b954038

File tree

13 files changed

+81
-62
lines changed

13 files changed

+81
-62
lines changed

.travis.yml

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,21 @@ timeouts:
1111
rvm:
1212
- 1.8.7
1313
- 1.9.3
14-
- 2.0.0
14+
- 2.2
1515
env:
1616
global: REDMINE_DIR=./workspace/redmine
1717
matrix:
18-
- REDMINE=2.5.3
1918
- REDMINE=2.6-stable
20-
- REDMINE=v3.8.0
19+
- REDMINE=3.2-stable
2120
- REDMINE=master
2221
matrix:
23-
include:
24-
- rvm: 2.2.2
25-
env: REDMINE=master
26-
gemfile: workspace/redmine/Gemfile
27-
- rvm: 2.1.6
28-
env: REDMINE=master
29-
gemfile: workspace/redmine/Gemfile
30-
- rvm: 2.1.6
31-
env: REDMINE=2.6-stable
32-
gemfile: workspace/redmine/Gemfile
3322
exclude:
3423
- rvm: 1.8.7
35-
env: REDMINE=master
24+
env: REDMINE=3.2-stable
3625
gemfile: workspace/redmine/Gemfile
3726
- rvm: 1.8.7
38-
env: REDMINE=v3.8.0
39-
gemfile: workspace/redmine/Gemfile
40-
- rvm: 2.0.0
41-
env: REDMINE=v3.8.0
42-
gemfile: workspace/redmine/Gemfile
43-
- rvm: 2.0.0
4427
env: REDMINE=master
4528
gemfile: workspace/redmine/Gemfile
46-
allow_failures:
47-
- env: REDMINE=v3.8.0
4829
gemfile: workspace/redmine/Gemfile
4930
before_install:
5031
- ./script/ci.sh clone_redmine --target $REDMINE_DIR
@@ -59,4 +40,4 @@ before_script:
5940
- 'phantomjs --webdriver 4444 2>&- 1>&- &'
6041
script:
6142
- ./script/ci.sh run_tests
62-
- ./script/ci.sh test_uninstall
43+
- ./script/ci.sh test_uninstall

app/models/ldap_setting.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ class LdapSetting
6868

6969
[:login, *User::STANDARD_FIELDS].each {|f| module_eval("def #{f}; auth_source_ldap.attr_#{f}; end") }
7070

71-
LdapError = (Gem.loaded_specs['net-ldap'].version.to_s >= '0.12.0' ? Net::LDAP::Error : Net::LDAP::LdapError)
72-
7371
def id
7472
@auth_source_ldap_id
7573
end
@@ -288,7 +286,7 @@ def validate_groupname_pattern
288286

289287
def validate_group_filter
290288
Net::LDAP::Filter.construct(group_search_filter) if group_search_filter.present?
291-
rescue LdapError
289+
rescue Net::LDAP::Error
292290
errors.add :group_search_filter, :invalid
293291
end
294292

config/Gemfile.travis

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
group :test do
2-
gem 'coveralls', :require => false
3-
if RUBY_VERSION < "1.9.3"
4-
gem "rest-client", "~> 1.6.8"
5-
gem "simplecov", "~> 0.8.2"
6-
gem "rcov", "= 0.9.11"
7-
gem "i18n", "~> 0.6.11"
2+
if RUBY_VERSION >= "2.0"
3+
gem 'coveralls', require: => false
4+
end
5+
if RUBY_VERSION < "1.9"
6+
gem 'i18n', '~> 0.6.11'
7+
gem 'rack-cache', '= 1.2'
88
end
99
end

lib/ldap_sync/core_ext/ber.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1+
# encoding: utf-8
2+
# Copyright (C) 2011-2013 The Redmine LDAP Sync Authors
3+
#
4+
# This file is part of Redmine LDAP Sync.
5+
#
6+
# Redmine LDAP Sync is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Redmine LDAP Sync is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with Redmine LDAP Sync. If not, see <http://www.gnu.org/licenses/>.
118
if ('0.12.0'..'0.13.0') === Gem.loaded_specs['net-ldap'].version.to_s
19+
require 'net/ber'
20+
221
##
322
# A String object with a BER identifier attached.
423
#

lib/ldap_sync/core_ext/ldap.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# encoding: utf-8
2+
# Copyright (C) 2011-2013 The Redmine LDAP Sync Authors
3+
#
4+
# This file is part of Redmine LDAP Sync.
5+
#
6+
# Redmine LDAP Sync is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Redmine LDAP Sync is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with Redmine LDAP Sync. If not, see <http://www.gnu.org/licenses/>.
18+
require 'net/ldap'
19+
20+
class Net::LDAP
21+
if Gem.loaded_specs['net-ldap'].version < Gem::Version.new('0.12.0')
22+
Error = LdapError
23+
end
24+
end

lib/ldap_sync/core_ext/ldap_entry.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#
1616
# You should have received a copy of the GNU General Public License
1717
# along with Redmine LDAP Sync. If not, see <http://www.gnu.org/licenses/>.
18+
require 'net/ldap'
19+
1820
class Net::LDAP
1921
class Entry
2022
include Enumerable

lib/ldap_sync/core_ext/string.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
require 'net/ldap'
1919

2020
module Net::BER::Extensions::String
21-
if Gem.loaded_specs['net-ldap'].version.to_s < '0.12.0'
21+
if Gem.loaded_specs['net-ldap'].version < Gem::Version.new('0.12.0')
2222
def raw_utf8_encoded
2323
if self.respond_to?(:encode) && self.encoding.name != 'ASCII-8BIT'
2424
self.encode('UTF-8').force_encoding('ASCII-8BIT')

lib/ldap_sync/entity_manager.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module LdapSync::EntityManager
2121
def connect_as_user?; setting.account.include?('$login'); end
2222

2323
private
24-
LdapError = (Gem.loaded_specs['net-ldap'].version.to_s >= '0.12.0' ? Net::LDAP::Error : Net::LDAP::LdapError)
25-
2624
def get_user_fields(username, user_data=nil, options={})
2725
fields_to_sync = setting.user_fields_to_sync
2826
if options.try(:fetch, :include_required, false)
@@ -318,7 +316,7 @@ def ldap_search(ldap, options, &block)
318316
result.map {|e| e[attrs] } unless block_given? || result.nil?
319317
rescue => exception
320318
os = ldap.get_operation_result
321-
raise LdapError, "LDAP Error(#{os.code}): #{os.message}"
319+
raise Net::LDAP::Error, "LDAP Error(#{os.code}): #{os.message}"
322320
end
323321

324322
def n(field)

script/ci.sh

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ setenv() {
2020
export MIGRATE_PLUGINS=redmine:plugins
2121
export REDMINE_TARBALL=https://github.com/edavis10/redmine/archive/$REDMINE.tar.gz
2222
;;
23-
2.*-stable) export PATH_TO_PLUGINS=./plugins # for redmine 2.x-stable
23+
*.*-stable) export PATH_TO_PLUGINS=./plugins # for redmine 2.x-stable
2424
export GENERATE_SECRET=generate_secret_token
2525
export MIGRATE_PLUGINS=redmine:plugins
2626
export REDMINE_SVN_REPO=http://svn.redmine.org/redmine/branches/$REDMINE
@@ -30,12 +30,6 @@ setenv() {
3030
export MIGRATE_PLUGINS=redmine:plugins
3131
export REDMINE_SVN_REPO=http://svn.redmine.org/redmine/trunk/
3232
;;
33-
v3.8.0) export PATH_TO_PLUGINS=./vendor/chiliproject_plugins
34-
export GENERATE_SECRET=generate_session_store
35-
export MIGRATE_PLUGINS=db:migrate:plugins
36-
export REDMINE_TARBALL=https://github.com/chiliproject/chiliproject/archive/$REDMINE.tar.gz
37-
export RUBYGEMS=1.8.29
38-
;;
3933
*) echo "Unsupported platform $REDMINE"
4034
exit 1
4135
;;
@@ -78,9 +72,6 @@ clone_redmine()
7872
mkdir -p $TARGET
7973
wget $REDMINE_TARBALL -O- | tar -C $TARGET -xz --strip=1 --show-transformed -f -
8074
fi
81-
82-
# Temporarily pin down database_cleaner for bug with sqlite, see https://github.com/bmabey/database_cleaner/issues/224
83-
sed -ri 's/gem "database_cleaner"/gem "database_cleaner", "< 1.1.0"/' $TARGET/Gemfile
8475
}
8576

8677
install_plugin_gemfile()

test/test_helper.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,19 @@
1616
# You should have received a copy of the GNU General Public License
1717
# along with Redmine LDAP Sync. If not, see <http://www.gnu.org/licenses/>.
1818

19-
require 'simplecov'
19+
if RUBY_VERSION >= '2.0.0'
20+
require 'simplecov'
2021

21-
SimpleCov.start do
22-
add_group 'Controllers', 'app/controllers'
23-
add_group 'Models', 'app/models'
24-
add_group 'Helpers', 'app/helpers'
25-
add_group 'Libraries', 'lib'
26-
add_filter '/test/'
27-
add_filter 'init.rb'
28-
root File.expand_path(File.dirname(__FILE__) + '/../')
29-
end if RUBY_VERSION >= '1.9.0'
22+
SimpleCov.start do
23+
add_group 'Controllers', 'app/controllers'
24+
add_group 'Models', 'app/models'
25+
add_group 'Helpers', 'app/helpers'
26+
add_group 'Libraries', 'lib'
27+
add_filter '/test/'
28+
add_filter 'init.rb'
29+
root File.expand_path(File.dirname(__FILE__) + '/../')
30+
end
31+
end
3032

3133
require File.expand_path(File.dirname(__FILE__) + '/../../../test/test_helper')
3234

0 commit comments

Comments
 (0)