activesupport 5.0.7.2 → 5.1.7
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activesupport might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +464 -694
- data/MIT-LICENSE +1 -1
- data/README.rdoc +1 -1
- data/lib/active_support.rb +8 -4
- data/lib/active_support/all.rb +3 -3
- data/lib/active_support/array_inquirer.rb +7 -5
- data/lib/active_support/backtrace_cleaner.rb +4 -4
- data/lib/active_support/benchmarkable.rb +3 -3
- data/lib/active_support/builder.rb +1 -1
- data/lib/active_support/cache.rb +41 -48
- data/lib/active_support/cache/file_store.rb +11 -20
- data/lib/active_support/cache/mem_cache_store.rb +30 -40
- data/lib/active_support/cache/memory_store.rb +13 -13
- data/lib/active_support/cache/null_store.rb +4 -4
- data/lib/active_support/cache/strategy/local_cache.rb +13 -22
- data/lib/active_support/cache/strategy/local_cache_middleware.rb +4 -5
- data/lib/active_support/callbacks.rb +649 -584
- data/lib/active_support/concurrency/load_interlock_aware_monitor.rb +17 -0
- data/lib/active_support/concurrency/share_lock.rb +20 -21
- data/lib/active_support/configurable.rb +5 -5
- data/lib/active_support/core_ext.rb +1 -2
- data/lib/active_support/core_ext/array.rb +7 -7
- data/lib/active_support/core_ext/array/access.rb +1 -1
- data/lib/active_support/core_ext/array/conversions.rb +15 -15
- data/lib/active_support/core_ext/array/grouping.rb +1 -1
- data/lib/active_support/core_ext/array/inquiry.rb +1 -1
- data/lib/active_support/core_ext/array/prepend_and_append.rb +1 -1
- data/lib/active_support/core_ext/benchmark.rb +1 -1
- data/lib/active_support/core_ext/big_decimal.rb +1 -1
- data/lib/active_support/core_ext/big_decimal/conversions.rb +4 -6
- data/lib/active_support/core_ext/class.rb +2 -2
- data/lib/active_support/core_ext/class/attribute.rb +5 -5
- data/lib/active_support/core_ext/class/attribute_accessors.rb +1 -1
- data/lib/active_support/core_ext/class/subclasses.rb +18 -4
- data/lib/active_support/core_ext/date.rb +5 -5
- data/lib/active_support/core_ext/date/acts_like.rb +1 -1
- data/lib/active_support/core_ext/date/blank.rb +1 -1
- data/lib/active_support/core_ext/date/calculations.rb +8 -8
- data/lib/active_support/core_ext/date/conversions.rb +12 -12
- data/lib/active_support/core_ext/date/zones.rb +2 -2
- data/lib/active_support/core_ext/date_and_time/calculations.rb +27 -22
- data/lib/active_support/core_ext/date_and_time/compatibility.rb +1 -1
- data/lib/active_support/core_ext/date_and_time/zones.rb +7 -8
- data/lib/active_support/core_ext/date_time.rb +5 -5
- data/lib/active_support/core_ext/date_time/acts_like.rb +2 -2
- data/lib/active_support/core_ext/date_time/blank.rb +1 -1
- data/lib/active_support/core_ext/date_time/calculations.rb +20 -10
- data/lib/active_support/core_ext/date_time/compatibility.rb +2 -2
- data/lib/active_support/core_ext/date_time/conversions.rb +12 -12
- data/lib/active_support/core_ext/digest/uuid.rb +4 -4
- data/lib/active_support/core_ext/enumerable.rb +23 -12
- data/lib/active_support/core_ext/file.rb +1 -1
- data/lib/active_support/core_ext/file/atomic.rb +4 -4
- data/lib/active_support/core_ext/hash.rb +9 -9
- data/lib/active_support/core_ext/hash/compact.rb +12 -9
- data/lib/active_support/core_ext/hash/conversions.rb +36 -37
- data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -2
- data/lib/active_support/core_ext/hash/keys.rb +6 -6
- data/lib/active_support/core_ext/hash/reverse_merge.rb +1 -1
- data/lib/active_support/core_ext/hash/slice.rb +4 -4
- data/lib/active_support/core_ext/hash/transform_values.rb +1 -0
- data/lib/active_support/core_ext/integer.rb +3 -3
- data/lib/active_support/core_ext/integer/inflections.rb +1 -1
- data/lib/active_support/core_ext/integer/time.rb +2 -2
- data/lib/active_support/core_ext/kernel.rb +4 -4
- data/lib/active_support/core_ext/kernel/concern.rb +1 -1
- data/lib/active_support/core_ext/kernel/reporting.rb +1 -1
- data/lib/active_support/core_ext/load_error.rb +1 -18
- data/lib/active_support/core_ext/module.rb +11 -12
- data/lib/active_support/core_ext/module/aliasing.rb +3 -48
- data/lib/active_support/core_ext/module/attr_internal.rb +4 -4
- data/lib/active_support/core_ext/module/attribute_accessors.rb +11 -5
- data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +20 -13
- data/lib/active_support/core_ext/module/concerning.rb +1 -1
- data/lib/active_support/core_ext/module/delegation.rb +85 -16
- data/lib/active_support/core_ext/module/introspection.rb +3 -11
- data/lib/active_support/core_ext/module/reachable.rb +2 -2
- data/lib/active_support/core_ext/numeric.rb +4 -4
- data/lib/active_support/core_ext/numeric/conversions.rb +3 -9
- data/lib/active_support/core_ext/numeric/inquiry.rb +21 -21
- data/lib/active_support/core_ext/numeric/time.rb +5 -5
- data/lib/active_support/core_ext/object.rb +12 -12
- data/lib/active_support/core_ext/object/blank.rb +3 -1
- data/lib/active_support/core_ext/object/conversions.rb +4 -4
- data/lib/active_support/core_ext/object/deep_dup.rb +1 -1
- data/lib/active_support/core_ext/object/duplicable.rb +34 -4
- data/lib/active_support/core_ext/object/inclusion.rb +1 -1
- data/lib/active_support/core_ext/object/json.rb +26 -12
- data/lib/active_support/core_ext/object/to_param.rb +1 -1
- data/lib/active_support/core_ext/object/to_query.rb +8 -5
- data/lib/active_support/core_ext/object/try.rb +1 -1
- data/lib/active_support/core_ext/object/with_options.rb +12 -1
- data/lib/active_support/core_ext/range.rb +4 -4
- data/lib/active_support/core_ext/range/conversions.rb +1 -1
- data/lib/active_support/core_ext/regexp.rb +4 -0
- data/lib/active_support/core_ext/securerandom.rb +3 -3
- data/lib/active_support/core_ext/string.rb +13 -13
- data/lib/active_support/core_ext/string/access.rb +6 -6
- data/lib/active_support/core_ext/string/conversions.rb +2 -2
- data/lib/active_support/core_ext/string/filters.rb +3 -3
- data/lib/active_support/core_ext/string/indent.rb +4 -4
- data/lib/active_support/core_ext/string/inflections.rb +10 -14
- data/lib/active_support/core_ext/string/inquiry.rb +1 -1
- data/lib/active_support/core_ext/string/multibyte.rb +1 -1
- data/lib/active_support/core_ext/string/output_safety.rb +19 -20
- data/lib/active_support/core_ext/string/strip.rb +1 -1
- data/lib/active_support/core_ext/string/zones.rb +2 -2
- data/lib/active_support/core_ext/time.rb +5 -5
- data/lib/active_support/core_ext/time/acts_like.rb +1 -1
- data/lib/active_support/core_ext/time/calculations.rb +46 -29
- data/lib/active_support/core_ext/time/conversions.rb +15 -12
- data/lib/active_support/core_ext/time/zones.rb +3 -3
- data/lib/active_support/core_ext/uri.rb +2 -2
- data/lib/active_support/dependencies.rb +45 -46
- data/lib/active_support/dependencies/interlock.rb +1 -1
- data/lib/active_support/deprecation.rb +9 -8
- data/lib/active_support/deprecation/behaviors.rb +3 -3
- data/lib/active_support/deprecation/constant_accessor.rb +50 -0
- data/lib/active_support/deprecation/instance_delegator.rb +2 -2
- data/lib/active_support/deprecation/method_wrappers.rb +10 -3
- data/lib/active_support/deprecation/proxy_wrappers.rb +6 -4
- data/lib/active_support/deprecation/reporting.rb +7 -7
- data/lib/active_support/duration.rb +221 -28
- data/lib/active_support/duration/iso8601_parser.rb +66 -65
- data/lib/active_support/duration/iso8601_serializer.rb +11 -9
- data/lib/active_support/evented_file_update_checker.rb +59 -55
- data/lib/active_support/execution_wrapper.rb +3 -3
- data/lib/active_support/executor.rb +1 -1
- data/lib/active_support/file_update_checker.rb +54 -50
- data/lib/active_support/gem_version.rb +2 -2
- data/lib/active_support/gzip.rb +4 -4
- data/lib/active_support/hash_with_indifferent_access.rb +40 -28
- data/lib/active_support/i18n.rb +5 -5
- data/lib/active_support/i18n_railtie.rb +14 -9
- data/lib/active_support/inflections.rb +11 -11
- data/lib/active_support/inflector.rb +5 -5
- data/lib/active_support/inflector/inflections.rb +11 -9
- data/lib/active_support/inflector/methods.rb +52 -51
- data/lib/active_support/inflector/transliterate.rb +8 -11
- data/lib/active_support/json.rb +2 -2
- data/lib/active_support/json/decoding.rb +3 -3
- data/lib/active_support/json/encoding.rb +8 -7
- data/lib/active_support/key_generator.rb +17 -17
- data/lib/active_support/lazy_load_hooks.rb +2 -2
- data/lib/active_support/log_subscriber.rb +9 -7
- data/lib/active_support/log_subscriber/test_helper.rb +9 -9
- data/lib/active_support/logger.rb +3 -3
- data/lib/active_support/logger_silence.rb +3 -3
- data/lib/active_support/logger_thread_safe_level.rb +1 -1
- data/lib/active_support/message_encryptor.rb +77 -35
- data/lib/active_support/message_verifier.rb +7 -7
- data/lib/active_support/multibyte.rb +2 -2
- data/lib/active_support/multibyte/chars.rb +23 -21
- data/lib/active_support/multibyte/unicode.rb +68 -89
- data/lib/active_support/notifications.rb +7 -5
- data/lib/active_support/notifications/fanout.rb +3 -3
- data/lib/active_support/notifications/instrumenter.rb +5 -5
- data/lib/active_support/number_helper.rb +5 -4
- data/lib/active_support/number_helper/number_converter.rb +11 -11
- data/lib/active_support/number_helper/number_to_currency_converter.rb +3 -3
- data/lib/active_support/number_helper/number_to_delimited_converter.rb +1 -2
- data/lib/active_support/number_helper/number_to_human_converter.rb +8 -10
- data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -11
- data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
- data/lib/active_support/number_helper/number_to_phone_converter.rb +1 -3
- data/lib/active_support/number_helper/number_to_rounded_converter.rb +12 -32
- data/lib/active_support/number_helper/rounding_helper.rb +64 -0
- data/lib/active_support/option_merger.rb +1 -1
- data/lib/active_support/ordered_hash.rb +3 -3
- data/lib/active_support/ordered_options.rb +6 -4
- data/lib/active_support/per_thread_registry.rb +5 -5
- data/lib/active_support/rails.rb +12 -6
- data/lib/active_support/railtie.rb +3 -3
- data/lib/active_support/reloader.rb +1 -1
- data/lib/active_support/rescuable.rb +6 -6
- data/lib/active_support/security_utils.rb +1 -1
- data/lib/active_support/string_inquirer.rb +8 -2
- data/lib/active_support/subscriber.rb +9 -5
- data/lib/active_support/tagged_logging.rb +4 -4
- data/lib/active_support/test_case.rb +12 -29
- data/lib/active_support/testing/assertions.rb +100 -2
- data/lib/active_support/testing/autorun.rb +2 -2
- data/lib/active_support/testing/constant_lookup.rb +0 -1
- data/lib/active_support/testing/declarative.rb +1 -1
- data/lib/active_support/testing/deprecation.rb +3 -2
- data/lib/active_support/testing/isolation.rb +15 -22
- data/lib/active_support/testing/method_call_assertions.rb +1 -1
- data/lib/active_support/testing/setup_and_teardown.rb +2 -2
- data/lib/active_support/testing/stream.rb +28 -28
- data/lib/active_support/testing/tagged_logging.rb +1 -1
- data/lib/active_support/testing/time_helpers.rb +45 -11
- data/lib/active_support/time.rb +12 -12
- data/lib/active_support/time_with_zone.rb +16 -14
- data/lib/active_support/values/time_zone.rb +100 -31
- data/lib/active_support/values/unicode_tables.dat +0 -0
- data/lib/active_support/version.rb +1 -1
- data/lib/active_support/xml_mini.rb +34 -36
- data/lib/active_support/xml_mini/jdom.rb +112 -112
- data/lib/active_support/xml_mini/libxml.rb +12 -11
- data/lib/active_support/xml_mini/libxmlsax.rb +13 -14
- data/lib/active_support/xml_mini/nokogiri.rb +10 -10
- data/lib/active_support/xml_mini/nokogirisax.rb +12 -13
- data/lib/active_support/xml_mini/rexml.rb +9 -9
- metadata +8 -9
- data/lib/active_support/concurrency/latch.rb +0 -26
- data/lib/active_support/core_ext/kernel/debugger.rb +0 -3
- data/lib/active_support/core_ext/module/method_transplanting.rb +0 -3
- data/lib/active_support/core_ext/module/qualified_const.rb +0 -70
- data/lib/active_support/core_ext/struct.rb +0 -3
- data/lib/active_support/core_ext/time/marshal.rb +0 -3
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "yaml"
|
2
2
|
|
3
3
|
YAML.add_builtin_type("omap") do |type, val|
|
4
|
-
ActiveSupport::OrderedHash[val.map{ |v| v.to_a.first }]
|
4
|
+
ActiveSupport::OrderedHash[val.map { |v| v.to_a.first }]
|
5
5
|
end
|
6
6
|
|
7
7
|
module ActiveSupport
|
@@ -25,7 +25,7 @@ module ActiveSupport
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def encode_with(coder)
|
28
|
-
coder.represent_seq
|
28
|
+
coder.represent_seq "!omap", map { |k, v| { k => v } }
|
29
29
|
end
|
30
30
|
|
31
31
|
def select(*args, &block)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "active_support/core_ext/object/blank"
|
2
|
+
|
1
3
|
module ActiveSupport
|
2
4
|
# Usually key value pairs are handled something like this:
|
3
5
|
#
|
@@ -36,10 +38,10 @@ module ActiveSupport
|
|
36
38
|
|
37
39
|
def method_missing(name, *args)
|
38
40
|
name_string = name.to_s
|
39
|
-
if name_string.chomp!(
|
41
|
+
if name_string.chomp!("=")
|
40
42
|
self[name_string] = args.first
|
41
43
|
else
|
42
|
-
bangs = name_string.chomp!(
|
44
|
+
bangs = name_string.chomp!("!")
|
43
45
|
|
44
46
|
if bangs
|
45
47
|
fetch(name_string.to_sym).presence || raise(KeyError.new("#{name_string} is blank."))
|
@@ -66,9 +68,9 @@ module ActiveSupport
|
|
66
68
|
def initialize(parent = nil)
|
67
69
|
if parent.kind_of?(OrderedOptions)
|
68
70
|
# use the faster _get when dealing with OrderedOptions
|
69
|
-
super() { |h,k| parent._get(k) }
|
71
|
+
super() { |h, k| parent._get(k) }
|
70
72
|
elsif parent
|
71
|
-
super() { |h,k| parent[k] }
|
73
|
+
super() { |h, k| parent[k] }
|
72
74
|
else
|
73
75
|
super()
|
74
76
|
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/core_ext/module/delegation"
|
2
2
|
|
3
3
|
module ActiveSupport
|
4
|
-
# NOTE: This approach has been deprecated for end-user code in favor of thread_mattr_accessor and friends.
|
4
|
+
# NOTE: This approach has been deprecated for end-user code in favor of {thread_mattr_accessor}[rdoc-ref:Module#thread_mattr_accessor] and friends.
|
5
5
|
# Please use that approach instead.
|
6
6
|
#
|
7
7
|
# This module is used to encapsulate access to thread local variables.
|
@@ -38,15 +38,15 @@ module ActiveSupport
|
|
38
38
|
# If the class has an initializer, it must accept no arguments.
|
39
39
|
module PerThreadRegistry
|
40
40
|
def self.extended(object)
|
41
|
-
object.instance_variable_set
|
41
|
+
object.instance_variable_set "@per_thread_registry_key", object.name.freeze
|
42
42
|
end
|
43
43
|
|
44
44
|
def instance
|
45
45
|
Thread.current[@per_thread_registry_key] ||= new
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
def method_missing(name, *args, &block)
|
48
|
+
private
|
49
|
+
def method_missing(name, *args, &block)
|
50
50
|
# Caches the method definition as a singleton method of the receiver.
|
51
51
|
#
|
52
52
|
# By letting #delegate handle it, we avoid an enclosure that'll capture args.
|
data/lib/active_support/rails.rb
CHANGED
@@ -9,19 +9,25 @@
|
|
9
9
|
# Rails and can change anytime.
|
10
10
|
|
11
11
|
# Defines Object#blank? and Object#present?.
|
12
|
-
require
|
12
|
+
require "active_support/core_ext/object/blank"
|
13
13
|
|
14
14
|
# Rails own autoload, eager_load, etc.
|
15
|
-
require
|
15
|
+
require "active_support/dependencies/autoload"
|
16
16
|
|
17
17
|
# Support for ClassMethods and the included macro.
|
18
|
-
require
|
18
|
+
require "active_support/concern"
|
19
19
|
|
20
20
|
# Defines Class#class_attribute.
|
21
|
-
require
|
21
|
+
require "active_support/core_ext/class/attribute"
|
22
22
|
|
23
23
|
# Defines Module#delegate.
|
24
|
-
require
|
24
|
+
require "active_support/core_ext/module/delegation"
|
25
25
|
|
26
26
|
# Defines ActiveSupport::Deprecation.
|
27
|
-
require
|
27
|
+
require "active_support/deprecation"
|
28
|
+
|
29
|
+
# Defines Regexp#match?.
|
30
|
+
#
|
31
|
+
# This should be removed when Rails needs Ruby 2.4 or later, and the require
|
32
|
+
# added where other Regexp extensions are being used (easy to grep).
|
33
|
+
require "active_support/core_ext/regexp"
|
@@ -21,11 +21,11 @@ module ActiveSupport
|
|
21
21
|
rescue TZInfo::DataSourceNotFound => e
|
22
22
|
raise e.exception "tzinfo-data is not present. Please add gem 'tzinfo-data' to your Gemfile and run bundle install"
|
23
23
|
end
|
24
|
-
require
|
24
|
+
require "active_support/core_ext/time/zones"
|
25
25
|
zone_default = Time.find_zone!(app.config.time_zone)
|
26
26
|
|
27
27
|
unless zone_default
|
28
|
-
raise
|
28
|
+
raise "Value assigned to config.time_zone not recognized. " \
|
29
29
|
'Run "rake time:zones:all" for a time zone names list.'
|
30
30
|
end
|
31
31
|
|
@@ -35,7 +35,7 @@ module ActiveSupport
|
|
35
35
|
# Sets the default week start
|
36
36
|
# If assigned value is not a valid day symbol (e.g. :sunday, :monday, ...), an exception will be raised.
|
37
37
|
initializer "active_support.initialize_beginning_of_week" do |app|
|
38
|
-
require
|
38
|
+
require "active_support/core_ext/date/calculations"
|
39
39
|
beginning_of_week_default = Date.find_beginning_of_week!(app.config.beginning_of_week)
|
40
40
|
|
41
41
|
Date.beginning_of_week_default = beginning_of_week_default
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "active_support/concern"
|
2
|
+
require "active_support/core_ext/class/attribute"
|
3
|
+
require "active_support/core_ext/string/inflections"
|
4
4
|
|
5
5
|
module ActiveSupport
|
6
6
|
# Rescuable module adds support for easier exception handling.
|
@@ -36,7 +36,7 @@ module ActiveSupport
|
|
36
36
|
# render xml: exception, status: 500
|
37
37
|
# end
|
38
38
|
#
|
39
|
-
#
|
39
|
+
# private
|
40
40
|
# def deny_access
|
41
41
|
# ...
|
42
42
|
# end
|
@@ -52,7 +52,7 @@ module ActiveSupport
|
|
52
52
|
if block_given?
|
53
53
|
with = block
|
54
54
|
else
|
55
|
-
raise ArgumentError,
|
55
|
+
raise ArgumentError, "Need a handler. Pass the with: keyword argument or provide a block."
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -74,7 +74,7 @@ module ActiveSupport
|
|
74
74
|
#
|
75
75
|
# If no handler matches the exception, check for a handler matching the
|
76
76
|
# (optional) exception.cause. If no handler matches the exception or its
|
77
|
-
# cause, this returns nil so you can deal with unhandled exceptions.
|
77
|
+
# cause, this returns +nil+, so you can deal with unhandled exceptions.
|
78
78
|
# Be sure to re-raise unhandled exceptions if this is what you expect.
|
79
79
|
#
|
80
80
|
# begin
|
@@ -8,15 +8,21 @@ module ActiveSupport
|
|
8
8
|
# you can call this:
|
9
9
|
#
|
10
10
|
# Rails.env.production?
|
11
|
+
#
|
12
|
+
# == Instantiating a new StringInquirer
|
13
|
+
#
|
14
|
+
# vehicle = ActiveSupport::StringInquirer.new('car')
|
15
|
+
# vehicle.car? # => true
|
16
|
+
# vehicle.bike? # => false
|
11
17
|
class StringInquirer < String
|
12
18
|
private
|
13
19
|
|
14
20
|
def respond_to_missing?(method_name, include_private = false)
|
15
|
-
method_name[-1] ==
|
21
|
+
(method_name[-1] == "?") || super
|
16
22
|
end
|
17
23
|
|
18
24
|
def method_missing(method_name, *arguments)
|
19
|
-
if method_name[-1] ==
|
25
|
+
if method_name[-1] == "?"
|
20
26
|
self == method_name[0..-2]
|
21
27
|
else
|
22
28
|
super
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require
|
1
|
+
require "active_support/per_thread_registry"
|
2
|
+
require "active_support/notifications"
|
2
3
|
|
3
4
|
module ActiveSupport
|
4
5
|
# ActiveSupport::Subscriber is an object set to consume
|
@@ -23,9 +24,8 @@ module ActiveSupport
|
|
23
24
|
# the +sql+ method.
|
24
25
|
class Subscriber
|
25
26
|
class << self
|
26
|
-
|
27
27
|
# Attach the subscriber to a namespace.
|
28
|
-
def attach_to(namespace, subscriber=new, notifier=ActiveSupport::Notifications)
|
28
|
+
def attach_to(namespace, subscriber = new, notifier = ActiveSupport::Notifications)
|
29
29
|
@namespace = namespace
|
30
30
|
@subscriber = subscriber
|
31
31
|
@notifier = notifier
|
@@ -52,11 +52,15 @@ module ActiveSupport
|
|
52
52
|
@@subscribers ||= []
|
53
53
|
end
|
54
54
|
|
55
|
+
# TODO Change this to private once we've dropped Ruby 2.2 support.
|
56
|
+
# Workaround for Ruby 2.2 "private attribute?" warning.
|
55
57
|
protected
|
56
58
|
|
57
59
|
attr_reader :subscriber, :notifier, :namespace
|
58
60
|
|
59
|
-
|
61
|
+
private
|
62
|
+
|
63
|
+
def add_event_subscriber(event) # :doc:
|
60
64
|
return if %w{ start finish }.include?(event.to_s)
|
61
65
|
|
62
66
|
pattern = "#{event}.#{namespace}"
|
@@ -91,7 +95,7 @@ module ActiveSupport
|
|
91
95
|
event.end = finished
|
92
96
|
event.payload.merge!(payload)
|
93
97
|
|
94
|
-
method = name.split(
|
98
|
+
method = name.split(".".freeze).first
|
95
99
|
send(method, event)
|
96
100
|
end
|
97
101
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "active_support/core_ext/module/delegation"
|
2
|
+
require "active_support/core_ext/object/blank"
|
3
|
+
require "logger"
|
4
|
+
require "active_support/logger"
|
5
5
|
|
6
6
|
module ActiveSupport
|
7
7
|
# Wraps any standard Logger object to provide tagging capabilities.
|
@@ -1,15 +1,15 @@
|
|
1
|
-
gem
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
1
|
+
gem "minitest" # make sure we get the gem, not stdlib
|
2
|
+
require "minitest"
|
3
|
+
require "active_support/testing/tagged_logging"
|
4
|
+
require "active_support/testing/setup_and_teardown"
|
5
|
+
require "active_support/testing/assertions"
|
6
|
+
require "active_support/testing/deprecation"
|
7
|
+
require "active_support/testing/declarative"
|
8
|
+
require "active_support/testing/isolation"
|
9
|
+
require "active_support/testing/constant_lookup"
|
10
|
+
require "active_support/testing/time_helpers"
|
11
|
+
require "active_support/testing/file_fixtures"
|
12
|
+
require "active_support/core_ext/kernel/reporting"
|
13
13
|
|
14
14
|
module ActiveSupport
|
15
15
|
class TestCase < ::Minitest::Test
|
@@ -66,23 +66,6 @@ module ActiveSupport
|
|
66
66
|
alias :assert_not_respond_to :refute_respond_to
|
67
67
|
alias :assert_not_same :refute_same
|
68
68
|
|
69
|
-
|
70
|
-
# Assertion that the block should not raise an exception.
|
71
|
-
#
|
72
|
-
# Passes if evaluated code in the yielded block raises no exception.
|
73
|
-
#
|
74
|
-
# assert_nothing_raised do
|
75
|
-
# perform_service(param: 'no_exception')
|
76
|
-
# end
|
77
|
-
def assert_nothing_raised(*args)
|
78
|
-
if args.present?
|
79
|
-
ActiveSupport::Deprecation.warn(
|
80
|
-
"Passing arguments to assert_nothing_raised " \
|
81
|
-
"is deprecated and will be removed in Rails 5.1.")
|
82
|
-
end
|
83
|
-
yield
|
84
|
-
end
|
85
|
-
|
86
69
|
ActiveSupport.run_load_hooks(:active_support_test_case, self)
|
87
70
|
end
|
88
71
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'active_support/core_ext/object/blank'
|
2
|
-
|
3
1
|
module ActiveSupport
|
4
2
|
module Testing
|
5
3
|
module Assertions
|
4
|
+
UNTRACKED = Object.new # :nodoc:
|
5
|
+
|
6
6
|
# Asserts that an expression is not truthy. Passes if <tt>object</tt> is
|
7
7
|
# +nil+ or +false+. "Truthy" means "considered true in a conditional"
|
8
8
|
# like <tt>if foo</tt>.
|
@@ -19,6 +19,17 @@ module ActiveSupport
|
|
19
19
|
assert !object, message
|
20
20
|
end
|
21
21
|
|
22
|
+
# Assertion that the block should not raise an exception.
|
23
|
+
#
|
24
|
+
# Passes if evaluated code in the yielded block raises no exception.
|
25
|
+
#
|
26
|
+
# assert_nothing_raised do
|
27
|
+
# perform_service(param: 'no_exception')
|
28
|
+
# end
|
29
|
+
def assert_nothing_raised
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
|
22
33
|
# Test numeric difference between the return value of an expression as a
|
23
34
|
# result of what is evaluated in the yielded block.
|
24
35
|
#
|
@@ -94,6 +105,93 @@ module ActiveSupport
|
|
94
105
|
def assert_no_difference(expression, message = nil, &block)
|
95
106
|
assert_difference expression, 0, message, &block
|
96
107
|
end
|
108
|
+
|
109
|
+
# Assertion that the result of evaluating an expression is changed before
|
110
|
+
# and after invoking the passed in block.
|
111
|
+
#
|
112
|
+
# assert_changes 'Status.all_good?' do
|
113
|
+
# post :create, params: { status: { ok: false } }
|
114
|
+
# end
|
115
|
+
#
|
116
|
+
# You can pass the block as a string to be evaluated in the context of
|
117
|
+
# the block. A lambda can be passed for the block as well.
|
118
|
+
#
|
119
|
+
# assert_changes -> { Status.all_good? } do
|
120
|
+
# post :create, params: { status: { ok: false } }
|
121
|
+
# end
|
122
|
+
#
|
123
|
+
# The assertion is useful to test side effects. The passed block can be
|
124
|
+
# anything that can be converted to string with #to_s.
|
125
|
+
#
|
126
|
+
# assert_changes :@object do
|
127
|
+
# @object = 42
|
128
|
+
# end
|
129
|
+
#
|
130
|
+
# The keyword arguments :from and :to can be given to specify the
|
131
|
+
# expected initial value and the expected value after the block was
|
132
|
+
# executed.
|
133
|
+
#
|
134
|
+
# assert_changes :@object, from: nil, to: :foo do
|
135
|
+
# @object = :foo
|
136
|
+
# end
|
137
|
+
#
|
138
|
+
# An error message can be specified.
|
139
|
+
#
|
140
|
+
# assert_changes -> { Status.all_good? }, 'Expected the status to be bad' do
|
141
|
+
# post :create, params: { status: { incident: true } }
|
142
|
+
# end
|
143
|
+
def assert_changes(expression, message = nil, from: UNTRACKED, to: UNTRACKED, &block)
|
144
|
+
exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) }
|
145
|
+
|
146
|
+
before = exp.call
|
147
|
+
retval = yield
|
148
|
+
|
149
|
+
unless from == UNTRACKED
|
150
|
+
error = "#{expression.inspect} isn't #{from.inspect}"
|
151
|
+
error = "#{message}.\n#{error}" if message
|
152
|
+
assert from === before, error
|
153
|
+
end
|
154
|
+
|
155
|
+
after = exp.call
|
156
|
+
|
157
|
+
if to == UNTRACKED
|
158
|
+
error = "#{expression.inspect} didn't changed"
|
159
|
+
error = "#{message}.\n#{error}" if message
|
160
|
+
assert_not_equal before, after, error
|
161
|
+
else
|
162
|
+
error = "#{expression.inspect} didn't change to #{to}"
|
163
|
+
error = "#{message}.\n#{error}" if message
|
164
|
+
assert to === after, error
|
165
|
+
end
|
166
|
+
|
167
|
+
retval
|
168
|
+
end
|
169
|
+
|
170
|
+
# Assertion that the result of evaluating an expression is changed before
|
171
|
+
# and after invoking the passed in block.
|
172
|
+
#
|
173
|
+
# assert_no_changes 'Status.all_good?' do
|
174
|
+
# post :create, params: { status: { ok: true } }
|
175
|
+
# end
|
176
|
+
#
|
177
|
+
# An error message can be specified.
|
178
|
+
#
|
179
|
+
# assert_no_changes -> { Status.all_good? }, 'Expected the status to be good' do
|
180
|
+
# post :create, params: { status: { ok: false } }
|
181
|
+
# end
|
182
|
+
def assert_no_changes(expression, message = nil, &block)
|
183
|
+
exp = expression.respond_to?(:call) ? expression : -> { eval(expression.to_s, block.binding) }
|
184
|
+
|
185
|
+
before = exp.call
|
186
|
+
retval = yield
|
187
|
+
after = exp.call
|
188
|
+
|
189
|
+
error = "#{expression.inspect} did change to #{after}"
|
190
|
+
error = "#{message}.\n#{error}" if message
|
191
|
+
assert_equal before, after, error
|
192
|
+
|
193
|
+
retval
|
194
|
+
end
|
97
195
|
end
|
98
196
|
end
|
99
197
|
end
|