2015/07/12分のコミットです。
CHANGELOGへの追加はありませんでした。
Add tests to ensure we don't interfere with json gem's output
ActiveSupportのテストの修正です。
active_support/json
をロードした場合に、JSON gemが正常に動作する事を確認する為のテストを追加しています。
ActiveSupport 4.2 で、active_support/json
をロードした場合 json gemの挙動を壊してしまうバグがあり、その確認の為に追加したようです。
issueはこちら。
以下の様な処理を行った場合に、問題が起きていました。
irb(main):001:0> require 'json' => true irb(main):002:0> obj = Struct.new(:key).new => #<struct key=nil> irb(main):003:0> JSON.dump([obj]) => "[\"#<struct key=nil>\"]" irb(main):004:0> require 'active_support/json' => true irb(main):005:0> JSON.dump([obj]) #=> SystemStackError: stack level too deep
active_support/json
では、to_json
メソッドを呼び出すと、active_support/json
内で追加したto_json_with_active_support_encoder
メソッドが呼ばれるよう対応しています(Rails 4.2まではalias_method_chain
を使用して実施)。
で、Fix #to_json for BasicObject Enumerables by codeodor · Pull Request #10278 · rails/rails の対応で、Enumerable
moduleにもto_json_with_active_support_encoder
メソッドを追加したのですが、JSON gemでは Enumerable
moduleに to_json
が定義されていない為、Object#to_json
に対してaliasが設定されてしまい、メソッドの呼び出しがループしてしまっていたようです。 Object
クラスより先にEnumerable
クラスにactive_support_encoder
メソッドの設定をする事で対応しています。
なお、masterブランチではalias_method_chain
が使われなくなっている(Module#prepend
)ので、問題はおきていません。
Expand the JSON test coverage for Struct and Hash (?!)
activesupport/test/json/encoding_test_cases.rb
の修正です。
JSON のテストに、Hash
クラス、及びStruct
クラスを使用した場合のテストを追加しています。
Expand coverage of JSON gem tests
activesupport/test/core_ext/object/json_gem_encoding_test.rb
の修正です。
JSON gemを使用したテストで、共通部分をメソッドに切り出しています。
added description instead of remove usage [ci skip]
actionpack/lib/action_controller/metal/renderers.rb
、
actionpack/lib/action_dispatch/http/mime_type.rb
のdocの修正です。
各メソッドのdocに、メソッドについての説明を追加しています。
fix typo in caching guide [ci skip]
rails guideのCaching with Rails: An Overview
の修正です。
Russian Doll Caching
の項、view cacheのexampleにタイポがあったのを修正しています。