Skip to content

Commit e8cd3c7

Browse files
committed
Fix tests
1 parent 5078d82 commit e8cd3c7

13 files changed

+87
-93
lines changed

.travis.yml

+6-28
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,34 @@
11
---
22
language: ruby
33
sudo: false
4+
cache: bundler
45
addons:
56
apt:
67
packages:
78
- ldap-utils
89
- slapd
9-
timeouts:
10-
bundle: 600
1110
rvm:
1211
- 1.8.7
1312
- 1.9.3
14-
- 2.0.0
13+
- 2.2
1514
env:
1615
global: REDMINE_DIR=./workspace/redmine
1716
matrix:
18-
- REDMINE=2.5.3
1917
- REDMINE=2.6-stable
20-
- REDMINE=v3.8.0
18+
- REDMINE=3.2-stable
2119
- REDMINE=master
2220
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
3321
exclude:
3422
- rvm: 1.8.7
35-
env: REDMINE=master
36-
gemfile: workspace/redmine/Gemfile
23+
env: REDMINE=3.2-stable
3724
- 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
4425
env: REDMINE=master
45-
gemfile: workspace/redmine/Gemfile
46-
allow_failures:
47-
- env: REDMINE=v3.8.0
4826
gemfile: workspace/redmine/Gemfile
27+
bundler_args: "--gemfile workspace/redmine/Gemfile --path workspace/redmine/vendor/bundle --without development rmagick"
4928
before_install:
5029
- ./script/ci.sh clone_redmine --target $REDMINE_DIR
5130
- cp ./config/database.yml.travis $REDMINE_DIR/config/database.yml
5231
- ./script/ci.sh install_plugin_gemfile
53-
install: ./script/ci.sh bundle_install
5432
before_script:
5533
- mysql -e 'CREATE DATABASE redmine CHARACTER SET utf8;'
5634
- ./script/ci.sh prepare_redmine
@@ -59,4 +37,4 @@ before_script:
5937
- 'phantomjs --webdriver 4444 2>&- 1>&- &'
6038
script:
6139
- ./script/ci.sh run_tests
62-
- ./script/ci.sh test_uninstall
40+
- ./script/ci.sh test_uninstall

app/models/ldap_setting.rb

+1-3
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

+6-6
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

+19
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

+24
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

+2
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

+1-1
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

+1-3
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

+5-36
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,17 @@ setenv() {
1212
fi
1313
if [ "$VERBOSE" = "yes" ]; then export TRACE=--trace; fi
1414
if [ ! "$VERBOSE" = "yes" ]; then export QUIET=--quiet; fi
15-
if [[ "$RUBY_VERSION" < "1.9" ]]; then export RUBYGEMS=2.1.11; fi
1615

1716
case $REDMINE in
1817
2.*.*) export PATH_TO_PLUGINS=./plugins # for redmine 2.x.x
19-
export GENERATE_SECRET=generate_secret_token
20-
export MIGRATE_PLUGINS=redmine:plugins
2118
export REDMINE_TARBALL=https://github.com/edavis10/redmine/archive/$REDMINE.tar.gz
2219
;;
23-
2.*-stable) export PATH_TO_PLUGINS=./plugins # for redmine 2.x-stable
24-
export GENERATE_SECRET=generate_secret_token
25-
export MIGRATE_PLUGINS=redmine:plugins
20+
*.*-stable) export PATH_TO_PLUGINS=./plugins # for redmine 2.x-stable
2621
export REDMINE_SVN_REPO=http://svn.redmine.org/redmine/branches/$REDMINE
2722
;;
2823
master) export PATH_TO_PLUGINS=./plugins
29-
export GENERATE_SECRET=generate_secret_token
30-
export MIGRATE_PLUGINS=redmine:plugins
3124
export REDMINE_SVN_REPO=http://svn.redmine.org/redmine/trunk/
3225
;;
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-
;;
3926
*) echo "Unsupported platform $REDMINE"
4027
exit 1
4128
;;
@@ -78,9 +65,6 @@ clone_redmine()
7865
mkdir -p $TARGET
7966
wget $REDMINE_TARBALL -O- | tar -C $TARGET -xz --strip=1 --show-transformed -f -
8067
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
8468
}
8569

8670
install_plugin_gemfile()
@@ -91,20 +75,6 @@ install_plugin_gemfile()
9175
ln -s "$PATH_TO_LDAPSYNC/config/Gemfile.travis" "$REDMINE_DIR/$PATH_TO_PLUGINS/redmine_ldap_sync/Gemfile"
9276
}
9377

94-
bundle_install()
95-
{
96-
setenv
97-
98-
if [ -n "${RUBYGEMS}" ]; then
99-
rvm rubygems ${RUBYGEMS} --force
100-
fi
101-
pushd $REDMINE_DIR 1> /dev/null
102-
for i in {1..3}; do
103-
gem install bundler $QUIET --no-rdoc --no-ri && \
104-
bundle install $QUIET --gemfile=./Gemfile --path vendor/bundle --without development rmagick && break
105-
done && popd 1> /dev/null
106-
}
107-
10878
prepare_redmine()
10979
{
11080
setenv
@@ -118,7 +88,7 @@ prepare_redmine()
11888
bundle exec rake redmine:load_default_data REDMINE_LANG=en $TRACE
11989

12090
trace 'Session token'
121-
bundle exec rake $GENERATE_SECRET $TRACE
91+
bundle exec rake generate_secret_token $TRACE
12292

12393
popd 1> /dev/null
12494
}
@@ -132,7 +102,7 @@ prepare_plugin()
132102
ln -s $PATH_TO_LDAPSYNC/* $PATH_TO_PLUGINS/redmine_ldap_sync
133103

134104
trace 'Prepare plugins'
135-
bundle exec rake $MIGRATE_PLUGINS NAME=redmine_ldap_sync $TRACE
105+
bundle exec rake redmine:plugins NAME=redmine_ldap_sync $TRACE
136106

137107
popd 1> /dev/null
138108
}
@@ -179,7 +149,7 @@ run_tests()
179149

180150
pushd $REDMINE_DIR 1> /dev/null
181151

182-
if [ "$REDMINE" == "master" ] && [ "$RUBY_VERSION" == "2.2.2" ]; then
152+
if [ "$REDMINE" == "master" ] && [ "$RUBY_VERSION" == "2.2" ]; then
183153
bundle exec rake redmine:plugins:ldap_sync:coveralls:test $TRACE
184154
else
185155
bundle exec rake redmine:plugins:ldap_sync:test $TRACE
@@ -194,15 +164,14 @@ test_uninstall()
194164

195165
pushd $REDMINE_DIR 1> /dev/null
196166

197-
bundle exec rake $TRACE $MIGRATE_PLUGINS NAME=redmine_ldap_sync VERSION=0
167+
bundle exec rake $TRACE redmine:plugins NAME=redmine_ldap_sync VERSION=0
198168

199169
popd 1> /dev/null
200170
}
201171

202172
case "$1" in
203173
"clone_redmine") shift; clone_redmine $@;;
204174
"install_plugin_gemfile") shift; install_plugin_gemfile $@;;
205-
"bundle_install") shift; bundle_install $@;;
206175
"prepare_redmine") shift; prepare_redmine $@;;
207176
"prepare_plugin") shift; prepare_plugin $@;;
208177
"start_ldap") shift; start_ldap $@;;

test/test_helper.rb

+12-10
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

test/ui/ldap_setting_test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
require File.expand_path('../../../../../test/ui/base', __FILE__)
1919
require File.expand_path('../../test_helper', __FILE__)
2020

21-
require 'simplecov'
22-
SimpleCov.command_name 'UI Tests'
21+
if RUBY_VERSION >= '2.0.0'
22+
require 'simplecov'
23+
SimpleCov.command_name 'UI Tests'
24+
end
2325

2426
class Redmine::UiTest::LdapSettingTest < Redmine::UiTest::Base
2527
fixtures :auth_sources, :users, :settings, :custom_fields

test/ui/login_test.rb

+4-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
require File.expand_path('../../../../../test/ui/base', __FILE__)
1919
require File.expand_path('../../test_helper', __FILE__)
2020

21-
require 'simplecov'
22-
SimpleCov.command_name 'UI Tests'
21+
if RUBY_VERSION >= '2.0.0'
22+
require 'simplecov'
23+
SimpleCov.command_name 'UI Tests'
24+
end
2325

2426
class Redmine::UiTest::LoginTest < Redmine::UiTest::Base
2527
fixtures :auth_sources, :users, :settings, :custom_fields, :roles, :projects, :members, :member_roles

test/unit/auth_source_ldap_test.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,8 @@ class AuthSourceLdapTest < ActiveSupport::TestCase
458458
assert_equal '[email protected]', @user.mail
459459
assert_equal 'User', @user.firstname
460460
assert_equal 'Misc', @user.lastname
461-
assert_equal 'en', @user.custom_field_values[0].value
462-
assert_equal '0', @user.custom_field_values[1].value
461+
assert_include @user.custom_field_values[0].value, ['en',nil]
462+
assert_include @user.custom_field_values[1].value, ['0', nil]
463463
end
464464

465465
test "#sync_user should delete groups" do

0 commit comments

Comments
 (0)