1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activesupport/test
Godfrey Chan debe7aedda Properly dump primitive-like AS::SafeBuffer strings as YAML
`coder.represent_scalar` means something along the lines of "Here is a quoted
string, you can just add it to the output", which is not the case here. It only
works for simple strings that can appear unquoted in YAML, but causes problems
for e.g. primitive-like strings ("1", "true").

`coder.represent_object` on the other hand, means that "This is the Ruby-object
representation for this thing suitable for use in YAML dumping", which is what
we want here.

Before:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => true
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => false
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => 1
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => 1.1

 After:

   YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml  # => "Hello"
   YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml   # => "true"
   YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml  # => "false"
   YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml      # => "1"
   YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml    # => "1.1"

If we ever want Ruby to behave more like PHP or JavaScript though, this is an
excellent trick to use ;)
2015-02-11 17:08:13 -08:00
..
autoloading_fixtures fixes circularity check in dependencies 2014-10-25 14:06:33 +02:00
core_ext Revert 88d08f2ec9 2015-02-11 17:32:18 -02:00
dependencies
deprecation
file_fixtures introduce ActiveSupport::Testing::FileFixtures. 2015-01-28 12:29:34 +01:00
fixtures
json Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
notifications
testing introduce ActiveSupport::Testing::FileFixtures. 2015-01-28 12:29:34 +01:00
xml_mini Do not include Active Support on tests 2015-01-04 18:59:42 -03:00
abstract_unit.rb Default to sorting user's test cases for now 2014-09-08 05:32:16 -07:00
autoload_test.rb fix autoload tests 2014-10-05 20:28:36 +03:00
benchmarkable_test.rb
broadcast_logger_test.rb
caching_test.rb Remove conversion code for old Rails cache entry 2015-01-01 22:31:27 -03:00
callback_inheritance_test.rb
callbacks_test.rb Add config to halt callback chain on return false 2015-01-02 15:31:56 -08:00
class_cache_test.rb
clean_backtrace_test.rb missing activesupport test coverage 2014-07-19 17:15:40 -07:00
clean_logger_test.rb
concern_test.rb Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846 2015-01-31 23:12:41 -05:00
configurable_test.rb Privatize config_accessor as with attr_accessor 2015-02-06 01:12:07 +09:00
constantize_test_cases.rb Use safe_constantize. 2014-09-02 00:41:00 +08:00
dependencies_test.rb Remove LoadError#path hack for Ruby 1.9 2015-01-04 15:54:21 -03:00
dependencies_test_helpers.rb fixes circularity check in dependencies 2014-10-25 14:06:33 +02:00
deprecation_test.rb - Extracted silence_stream method to new module in activesupport/testing. 2015-01-20 22:28:48 +05:30
descendants_tracker_test_cases.rb
descendants_tracker_with_autoloading_test.rb
descendants_tracker_without_autoloading_test.rb
file_update_checker_test.rb
gzip_test.rb
hash_with_indifferent_access_test.rb - Moved hwia frozen value assignment test to hash_ext_test similar to other tests 2015-01-17 14:55:19 +05:30
i18n_test.rb remove unnecessary calling of I18n.backend.store_translations(empty, {}) 2014-06-15 08:53:58 +05:30
inflector_test.rb Replace Enumerable#reverse.each with Enumerable#reverse_each 2014-10-13 11:47:16 +01:00
inflector_test_cases.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
key_generator_test.rb missing activesupport test coverage 2014-07-19 17:15:40 -07:00
lazy_load_hooks_test.rb
load_paths_test.rb
log_subscriber_test.rb
logger_test.rb
message_encryptor_test.rb Remove "rescue" clause around "require 'openssl'" 2014-12-03 21:58:02 -08:00
message_verifier_test.rb Remove "rescue" clause around "require 'openssl'" 2014-12-03 21:58:02 -08:00
multibyte_chars_test.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
multibyte_conformance_test.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
multibyte_proxy_test.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
multibyte_test_helpers.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
multibyte_unicode_database_test.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
notifications_test.rb
number_helper_i18n_test.rb remove unnecessary calling of I18n.backend.store_translations(empty, {}) 2014-06-15 08:53:58 +05:30
number_helper_test.rb Merge pull request #12067 from jackxxu/keep_precision 2015-02-06 16:21:28 -02:00
option_merger_test.rb Add implicit receiver support to Object#with_options 2014-07-29 16:11:48 -04:00
ordered_hash_test.rb
ordered_options_test.rb
rescuable_test.rb Add class level case operator support for error dispatching in Rescuable 2014-12-10 02:34:59 +02:00
safe_buffer_test.rb Properly dump primitive-like AS::SafeBuffer strings as YAML 2015-02-11 17:08:13 -08:00
security_utils_test.rb Add AS::SecurityUtils.secure_compare for constant time string comparison 2014-10-23 14:54:06 -03:00
string_inquirer_test.rb
subscriber_test.rb Fix assertion arguments order 2014-07-31 08:56:22 -03:00
tagged_logging_test.rb
test_case_test.rb Change the default test order from :sorted to :random 2015-01-04 11:58:41 -03:00
time_travel_test.rb Change AS::Testing::TimeHelpers#travel_to to also stub DateTime.now 2015-02-03 05:23:23 -08:00
time_zone_test.rb make zones_map private 2015-02-06 22:46:38 -05:00
time_zone_test_helpers.rb Extract out with_env_tz helper method. 2014-06-18 19:46:04 +08:00
transliterate_test.rb Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
xml_mini_test.rb Fixes wording of test description 2015-02-11 14:07:56 -05:00