Update to a more performant random string implementation

Since `SecureRandom.alphanumeric` is Ruby 2.5 only, we can't use that
for now. Implement a new version until we can get Tracks updated to that
version.
This commit is contained in:
Matt Rogers 2018-10-19 09:25:15 -05:00
parent bb8fd08685
commit dea3b1b58e
No known key found for this signature in database
GPG key ID: 605D017C07EB4316

View file

@ -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)