2017/07/25分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
activerecord/CHANGELOG.md
Fix test failures when prepared statements are disabled
Active Recordの修正です。
先日行われたActive Recordのリファクタリング(Refactor Active Record to let Arel manage bind params)の影響で、prepared statementsをdiableにした場合にテストがコケていたのを修正しています。
partial queryを管理するためのcolletor classを作ったりして、まだちょっとリファクタリングを行っています。
Include rack-mini-profiler by default
railties/lib/rails/generators/rails/app/templates/Gemfile
の修正です。
デフォルトで生成されるGemfile
にMiniProfiler/rack-mini-profilerを追加しています。
が、まだ議論がされきってないのと、rack-mini-profiler
はモンキーパッチだらけで良くないのではという事で、後ほどrevertされています。
Revert “Include rack-mini-profiler by default”
というわけで、直前のrack-mini-profiler
をデフォルトのgemに追加した対応をrevertしています。
Merge pull request #29765 from lugray/fix_counter_cache
activerecord/lib/active_record/associations/builder/belongs_to.rb
、
activerecord/lib/active_record/counter_cache.rb
の修正です。
after_create
callbackの中でupdate_attributes
を使用した、かつ、複数のbelongs_to
assocationがあり、それぞれcounter cachesを使用している場合に、更新処理でcounter cachecが一度しかインクリメントされない事を確認するテストを追加しています。
元々は、上記条件の場合に2回インクリメントがされてしまっていたのですが、そちらのバグは違うコミットで直ってしまっていたので、このコミットではリグレッションテストだけを追加しています。
Merge pull request #29792 from lugray/delegate_respond_to
actionview/lib/action_view/helpers/controller_helper.rb
の修正です。
ActionView::Helpers::ControllerHelper
moduleにrespond_to?
メソッドを定義し、ControllerHelper
がcontrollerにdelegateするメソッド(request_forgery_protection_token
、params
等)については、controllerに対してrespond_to?
を行うよう修正しています。
Merge pull request #29853 from lugray/move_generator_namespacing_to_base
railties/lib/rails/generators/base.rb
、
railties/lib/rails/generators/named_base.rb
の修正です。
NamedBase
クラスに定義されていたnamespaceに関するメソッドを、Base
クラスに移動しています。namespaceを正しく扱えてないgeneratorでnamesapceを扱えるようにする為、との事です。んー、メソッド移動せず、NamedBase
クラスを使用するよう修正する、で良さそうな気もしたのですが…。
Merge pull request #29902 from y-yagi/fix_29880
railties/lib/rails/commands/server/server_command.rb
の修正です。
Pumaを使用している際、rails server
の起動メッセージにURLの情報(e.g. Rails 5.1.2 application starting in development on http://localhost:3000
のon http://localhost:3000
の部分)を出力しないよう修正しています。
PumaはPuma自体で独自のconfigを持てる、かつ、そこでhostやportの情報が定義出来てしまい、rails server
では実際に起動する際にしようするhostやportの情報を正しく知る事が出来ない為。
Fix warning: assigned but unused variable - comment
activerecord/test/cases/associations/belongs_to_associations_test.rb
の修正です。
test_multiple_counter_cache_with_after_create_update
から、使用していない変数を削除しています。
Merge pull request #29848 from kamipo/fix_distinct_count_with_order_and_limit
Active Recordの修正です。
Avoid unscope(:order)
when limit_value
is presented for count
で、limit_valueが指定されている場合は
unscope(:order)`を行わないよう修正したのですが、その影響でDISTINCT + COUNT + ORDER BY + LIMITを実行した場合に、不正なSQLが生成されてしまいエラーになってしまうバグがあったのを修正しています。
User.distinct.order(updated_at: :desc).limit(10).count
LINE 1: ...users"."id" AS count_column FROM "users" ORDER BY "users"."u...
User.distinct.order(updated_at: :desc).limit(10).count
Merge pull request #29897 from kirs/frozen-actionview
Action Viewの修正です。
各ファイルの先頭にfrozen_string_literal: true
を追加しています。
Suppress warning from actionview controller helper.
actionview/lib/action_view/helpers/controller_helper.rb
の修正です。
ActionView::Helpers::ControllerHelper
moduleでRubyのwarning(`*' interpreted as argument prefix
)が出ていたのをで、中括弧を追加し対応しています。
Merge pull request #29859 from dwightwatson/feature/rack-test
actionpack/actionpack.gemspec
の修正です。
rack-test
のが0.6系を使用するよう固定されていたのを、バージョンの上限ロックを行わないよう修正しています。
- s.add_dependency "rack-test", "~> 0.6.3"
+ s.add_dependency "rack-test", ">= 0.6.3"
remove depreciated assertion to eliminate warning
activesupport/test/hash_with_indifferent_access_test.rb
の修正です。
assert_equal
メソッドのexpected引数にnilを指定していたテストを、assert_nil
を使用するよう修正しています。
Minitest 5.10から上記使い方がdeprecateになり、nilを期待する場合はassert_nil
が使用する必要がある為。
Merge pull request #29898 from deivid-rodriguez/follow_up_to_multiple_location_engine_mounting
actionpack/lib/action_dispatch/routing/mapper.rb
、
actionpack/lib/action_dispatch/routing/routes_proxy.rb
の修正です。
一つのRails Engineを異なるlocationにmount出来るよう修正した、Allow mounting the same engine several times in different locations.の影響で、engineの route helpersを使用した際に正しいpathが取得出来ないバグが出来てしまっていたのを修正しています。
Merge pull request #29866 from rlue/master
actionpack/lib/action_controller/metal/strong_parameters.rb
のdocの修正です。
ActionController::Parameters#delete
メソッドのdocで、引数に指定されたkeyが存在しなかった場合の挙動の説明が実際の挙動と異なっていた(説明には、keyが存在しなかったからdefault valueを返すと書かれていたのが、実際返ってくるのはnil)のを修正しています。
Fix warning: ambiguous first argument
railties/test/application/rake/dbs_test.rb
の修正です。
db:schema:load
のテストでRubyのwarning(warning: ambiguous first argument; put parentheses or a space even after
)が出ていたので、中括弧を追加し対応しています。
Merge pull request #29919 from kirs/actionpack-frozen-friendly
Action Packの修正です。
ファイルの先頭にfrozen_string_literal: true
を追加、及び、Stringを変更する箇所でdup
を呼び出す等行い、エラーにならないよう対応しています。
Stop creating ApplicationRecord on model generation
Active Record、railtiesの修正です。
application_record.rb
が存在しない場合に、model generatorが自動でapplication_record.rb
を生成するようにしていたのを、生成しないよう修正しています。
元々Rails 5.0でapplication_record.rb
が導入された際に、移行用に自動で生成するようになっていたのですが、もう移行は不要だろうという事で生成しないようになっています。
代わりに、application_record.rb
を生成する為のgeneratorが追加されたので、今後application_record.rb
が必要になった場合は、そちらを使用する事で対応可能です。
Fix test_add_column_with_timestamp_type
when using Oracle
activerecord/test/cases/migration/change_schema_test.rb
の修正です。
test_add_column_with_timestamp_type
のテストがOracle adapterでエラーになっていたのを修正しています。
Extract assert_output
and available_pty?
into ConsoleHelpers
module
railtiesのテストの修正です。
各テストクラスで独自に定義していたconsole test用のヘルパーメソッドをmodule(ConsoleHelpers
)に切り出しています。
Suppress deprecated warning in Action Cable
Gemfile.lock
の修正です。
event_emitter
gemのバージョンを0.2.6に更新しています。0.2.6でFixnumに関する対応を行われており、deprecateメッセージが出ないようになっている為。
参考:Fix Fixnum warning on Ruby 2.4+
[ci skip] Add documentation for after_create_commit and after_update_commit callbacks
rails guideのActive Record Callbacks
の修正です。
Transaction Callbacks
の項に、after_create_commit
とafter_update_commit
を同じmodelに同時に定義した場合、後勝ち(後で定義した方のみ実行される)になってしまう事についての説明を追加しています。
Remove useless JoinInformation
Active Recordの修正です。
Refactor Active Record to let Arel manage bind paramsの対応により不要になったJoinInformation
Structを削除しています。
Remove unused queries_predicates
activerecord/lib/active_record/relation/predicate_builder/array_handler.rb
の修正です。
Refactor Active Record to let Arel manage bind paramsの対応により不要になったqueries_predicates
メソッドを削除しています。
Fix dbconsole
test when tempdir is a long path
railties/test/application/dbconsole_test.rb
の修正です。
dbconsole
のテストで、DB名を取得するのに.databases
を使用していたのを、pragma database_list;
を使用するよう修正しています。
.databases
だとpathが長い場合に適当なサイズに結果がトランケートされてしまい、正しく値が取得されない事がありました。しかしpragma database_list
だと結果がトランケートされない為、そちらを使用するようにしたとの事です。
Fix failing tests
activerecord/test/cases/relation/delegation_test.rb
の修正です。
Arelにdelegateするメソッドの一覧からbind_values
を削除しています。
bind_values
もう使わなくなった為。参考:Remove unused bind_values