2017/02/22分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Prefer
remove_method
overundef_method
when reloading routes - Add the
resolve
method to the routing DSL - Add the
direct
method to the routing DSL
Tiny documentation edits [ci skip]
actionpack/lib/action_dispatch/system_test_case.rb
のdoc及びrails guideのA Guide to Testing Rails Applications
の修正です。
グラマー及びフォーマットの修正を行っています。
Only load SystemTestCase if Capybara is defined
railties/lib/rails/test_help.rb
の修正です。
Capybaraが定義されている場合のに、ActionDispatch::SystemTestCase
クラスを読み込むよう修正しています。
Revert back to the original of using package.json in the root of the project (#28093)
railtiesの修正です。
vendor配下で管理されるようになっていたpackage.json及びnode_modulesを、vendor配下ではなくproject root配下で管理するよう戻しています。既に多くのエコシステムがrails rootでpackage.json及びnode_modulesを管理するようになっており、合わせた方が混乱が少ないだろう、という理由により戻したようです。
actionmailer/CHANGELOG.md
の修正です。
定数をバッククォートで囲むよう修正しています。
各ファイルで、リリース済みのarelを使用するよう修正しています。
actionmailer/CHANGELOG.md
の修正です。
コマンドをバッククォートで囲むよう修正しています。
activejob/CHANGELOG.md
の修正です。
CHANGELOGのエントリー間にあった不要なスペースを削除しています。
Fix schema leakage from dirty_test.rb
activerecord/test/cases/dirty_test.rb
の修正です。
filed
という名前のカラムを作成した場合のテストの後処理で、DBのcacheをclearするよう修正しています。clearしないと不要なカラムの除法を保持したままになってしまうため。
Add backticks around method names
activerecord/CHANGELOG.md
の修正です。
メソッド名をバッククォートで囲むよう修正しています。
Merge pull request #23138 from rails/custom-url-helpers-and-polymorphic-urls https://github.com/rails/rails/commit/f3d729f75363136f659f2cb78165ca5c899ecfe7
Action Packの修正です。
routesに関する改善がまとめて含まれています。まず、routesファイルで直接custom url helpersを作成出来るdirect
メソッドが追加されています。
例。
# routes.rb Rails.application.routes.draw do direct :homepage do "http://www.rubyonrails.org" end direct :commentable do |model| [ model, anchor: model.id ] end direct :main do { controller: 'pages', action: 'index', subdomain: 'www' } end end
irb(main):004:0> app.homepage_url # => "http://www.rubyonrails.org" irb(main):001:0> app.commentable_url(User.first) # => "http://www.example.com/users/298486374#298486374"
次に、routesファイルでmodelのpolymorphic mapping をカスタマイズする為のresolve
メソッドが追加されています。
# routes.rb Rails.application.routes.draw do resource :basket resolve "Basket" do [:basket] end end
上記のように定義した場合、link_to
やform_for
にBasket
クラスのインスタンスを渡した場合、/baskets/:id
というURLではなく、/basket
というURLが生成されるようになっています。
最後に、routesをreloadした際に、undef_method
ではなくremove_method
メソッドを使用するよう修正しています。親クラスに同名のメソッドが定義されていた場合に、そちらのメソッドは引き続き呼べるようにするためのようです。
[ci skip] Fix typos in direct/resolve changelog.
actionpack/CHANGELOG.md
の修正です。
先ほどコミットされたresolve、directメソッドの対応のentryにタイポがあったのを修正しています。
[ci skip] Fix direct/resolve documentation.
actionpack/lib/action_dispatch/routing/mapper.rb
のdocの修正です。
resolve、directメソッドのdocにタイポ及びフォーマットの修正を行っています。
Merge pull request #28042 from kamipo/add_changelog_for_27384
activerecord/CHANGELOG.md
の修正です。
整数型のPKがauto incrementになった対応(Tweak bigint PK handling、Correctly dump integer-like primary key with default nil)について、CHANGELOGのエントリーを追加しています。
Merge pull request #28095 from matthewd/nested-database-config
activerecord/lib/active_record/connection_adapters/connection_specification.rb
の修正です。
DB configファイルに3階層目を定義出来るよう修正しています。
例。
default: &default adapter: sqlite3 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> timeout: 5000 development: primary: <<: *default database: db/development.sqlite3 readonly: <<: *default database: db/readonly.sqlite3
上記のように、environment配下に更に定義を追加出来るようになっています。
[doc] Fix wrong class name in testing.md
rails guideのA Guide to Testing Rails Applications
の修正です。
Implementing a system test
の項のexampleコードのクラス名に誤りがあったのを修正しています。
remove needless extension from system test example [ci skip]
rails guideのA Guide to Testing Rails Applications
の修正です。
System Testクラスをgenerateする場合のexampleに不要な拡張子があったのを削除しています。
Preload to_datetime before freezing a TimeWithZone instance
activesupport/lib/active_support/time_with_zone.rb
の修正です。
TimeWithZone
のインスタンスをfreezeする際に、to_datetime
メソッドの結果もcacheするよう修正しています。
def freeze - period; utc; time # preload instance variables before freezing + # preload instance variables before freezing + period; utc; time; to_datetime super end
freeze
メソッド呼び出し後にto_datetime
メソッドが呼び出せるようにする為。
Add CHANGELOG entry for #28104
activesupport/CHANGELOG.md
の修正です。
直前のfreezeにto_datetime
メソッドの結果をcacheするようにした対応について、CHANGELOGのエントリーを追加しています。
activesupport/test/json/encoding_test_cases.rb
の修正です。
不足していたdate
、time
等のrequireを追加しています。
Bundler 1.14.5でrubygems/spec_fetcher
がlazy loadされるようになり、その影響で、元々はrequireされていたファイルがrequireされなくなった為、requireを追加したとのことです。
参考:Defer requiring rubygems/spec_fetcher until it becomes necessary · bundler/bundler@a78583c
Bump removal of /:controller/:action
to Rails 5.2
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
Rails 5.1で削除予定だったroutes.rbのpath parametersに:controller
、:action
を指定した場合の処理の削除を、Rails 5.2に削除するようdeprecateメッセージを変更しています。
if route.segment_keys.include?(:controller) ActiveSupport::Deprecation.warn(<<-MSG.squish) Using a dynamic :controller segment in a route is deprecated and - will be removed in Rails 5.1. + will be removed in Rails 5.2. MSG end
単純に対応が間に合わなかったからですかねえ。
actionpack/test/controller/live_stream_test.rb
、
activesupport/test/core_ext/string_ext_test.rb
の修正です。
不足していたtimeout
のrequireを追加しています。こちらもBundler 1.14.5の対応の影響。