diff --git a/test/test_helper.rb b/test/test_helper.rb index d0e82d8f..9c5aa0ac 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,6 +1,7 @@ ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' +require 'securerandom' # set config for tests. Overwrite those read from config/site.yml. Use inject to avoid warning about changing CONSTANT { @@ -10,6 +11,7 @@ require 'rails/test_help' "time_zone" => "Amsterdam" # force UTC+1 so Travis triggers time zone failures }.inject( SITE_CONFIG ) { |h, elem| h[elem[0]] = elem[1]; h } + class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. # @@ -38,13 +40,8 @@ class ActiveSupport::TestCase # for validation purposes # def generate_random_string(length) - string = "" - characters = %w(a b c d e f g h i j k l m n o p q r s t u v w z y z 1\ 0) - length.times do - pick = characters[rand(26)] - string << pick - end - return string + o = [('a'..'z'), ('A'..'Z'), (0..9)].flat_map(&:to_a) + (0...length).map { o[rand(o.length)] }.join end def assert_equal_dmy(date1, date2)