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
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
autoload_test.rb
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
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
dependencies_test.rb Remove LoadError#path hack for Ruby 1.9 2015-01-04 15:54:21 -03:00
dependencies_test_helpers.rb
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
inflector_test.rb
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
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
number_helper_test.rb Merge pull request #12067 from jackxxu/keep_precision 2015-02-06 16:21:28 -02:00
option_merger_test.rb
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
string_inquirer_test.rb
subscriber_test.rb
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
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