なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2016/07/27)

2016/07/27分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

railties/CHANGELOG.md

actionview/CHANGELOG.md


Quoting booleans should return a frozen string

activerecord/lib/active_record/connection_adapters/abstract/quoting.rbactiverecord/lib/active_record/connection_adapters/mysql/quoting.rbの修正。

quoting booleansをfreezeするよう修正しています。

      def quoted_true
-        "'t'"
+        "'t'".freeze
       end

freezeしておかないと、quoteした値を上書き出来てしまう為、それを避ける為にとの事です。

irb(main):001:0> ActiveRecord::Base.connection.quote(true) << ' foo'
=> "1 foo"
irb(main):002:0> ActiveRecord::Base.connection.quote(true) << ' foo'
=> "1 foo foo"

Merge pull request #25912 from stevenharman/fix_render_partial_collection_to_allow_custom_collection

actionview/lib/action_view/renderer/partial_renderer.rbの修正です。

collectionをpartial renderingする際に、collectionのto_aryメソッドを使用していたのを、to_aメソッドを使用するよう修正しています。

    def collection_from_options
       if @options.key?(:collection)
         collection = @options[:collection]
-        collection.respond_to?(:to_ary) ? collection.to_ary : []
+        collection ? collection.to_a : []
       end
     end

EnumeratorEnumerableインスタンスにはto_aryメソッドが定義されておらず、collectionに左記のクラスを指定した場合に、partial renderingが行えないという問題があった為修正したとの事です。


A generated app should not include Uglifier with --skip-javascript option.

railties/lib/rails/generators/app_base.rbrailties/lib/rails/generators/rails/app/templates/config/environments/production.rb.ttの修正です。

rails new--skip-javascriptオプションを指定した場合、Gemfileにuglifierを含まないよう修正しています。


Return ActionDispatch.test_app when no app is set on IntegrationTest.app method

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

IntegrationTest.test_appメソッドで、@@appnilの場合に、ActionDispatch.test_appを返すよう修正しています。が、後ほど再度修正が行われています。


Be more explicit with the expected result

actionpack/test/controller/integration_test.rbの修正です。

ActionDispatch::Integration.appメソッドのテストで、期待する値をより明確な値に修正しています。

-    assert_equal ActionDispatch.test_app, self.class.app
+    assert_equal 'fake_app', self.class.app

There are some cases where @@app is not defined

actionpack/lib/action_dispatch/testing/integration.rbの修正です。

IntegrationTest.test_appメソッドで、@@appを返す条件を、@@appが定義済み、かつ、nilで無い場合に修正しています。

        def app
-          @@app || ActionDispatch.test_app
+          if defined?(@@app) && @@app
+            @@app
+          else
+            ActionDispatch.test_app
+          end

@@appがそもそも定義されてないケースは色々とある為、との事です。


Merge pull request #25958 from kamipo/should_be_target_loaded

activerecord/test/cases/associations/has_many_associations_test.rbの修正です。

has_many associationに関する各テストで、対象のassociationがload済みである事を確認するassertionを追加しています。