なるようになるブログ

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

rails commit log流し読み(2016/02/01)

2016/02/01分のコミットです。

CHANGELOGへの追加はありませんでした。


Wait for EventMachine to finish starting

actioncable/test/client_test.rbの修正です。

テストの前処理で、EventMachineが起動するまでスレッドを待たせるよう修正しています。

     Thread.new { EventMachine.run } unless EventMachine.reactor_running?
+    Thread.pass until EventMachine.reactor_running?

Merge pull request #23368 from y-yagi/remove_backward_compatibility_code_for_minitest_4

guides/bug_report_templates/generic_master.rbの修正です。

汎用的に使うようのbug report templateに、Minitest 4系用の互換コードが(Minitest 5でクラス名がMiniTest::Unit::TestCaseからMinitest::Testに変わった事に関する対応)残っていたのを、削除しています。


Merge pull request #23369 from maclover7/actioncable-assets-redux

Action Cableの修正です。

CoffeeScriptで書かれていたAction Cableのjsを、gem リリース時に一つのJSにコンパイルするよう修正しています。

Action Cableの実装はCoffeeScriptで書かれていた為、Action Cableのruntime dependencycoffee-railsが必要だったのですが、それだとRailsを使用するユーザーにCoffeeScriptのインストールを強制する事になり、それは宜しく無いだろう、とう事で、リリース時にJSにコンパイルし、使用する際はCoffeeScriptは不要になるよう対応した、との事です。


Wrangle the asset build into something that sounds more general

Action Cableの修正です

各JSのパス、assetsをコンパイルした際の出力先をより適切な箇所に修正しています。


Drop the runtime dependency on coffee-rails

actioncable/actioncable.gemspecの修正です。

先の対応によりCoffeeScriptは不要になった為、runtime dependencyからcoffee-railsを削除しています。


Merge pull request #23169 from y-yagi/rake_proxy_in_engine

railtiesの修正です。

Rails Engine配下でもrake proxyが動作するよう対応しています。

これで、Rails Engineでもbin/railsコマンド経由で、rakeタスクを実行出来るようになっています。


Update middleware docs regarding ActionDispatch::LoadInterlock [ci skip]

Rails guideの修正です。

各guide内のmiddlewareについて説明している箇所から、デフォルトでは使用しなくなったRack::Lockについての削除、及び代わりに使用するようになったActionDispatch::LoadInterlockについての説明を追加しています。


Remove unused method

actioncable/test/client_test.rbの修正です。

使用していないclose!メソッドを削除しています。


clarify the touch true option does not trigger after_save/update [ci skip]

activerecord/lib/active_record/associations.rbのdocの修正です。

belongs_toメソッドtouchオプションについてのdocに、touchが実行される際はvalidationが実行されない事、及びafter_touchafter_commitafter_rollback callbackが実行される旨説明を追加しています。


Merge pull request #23370 from maclover7/actioncable-main-travis-build

.travis.ymlの修正です。

Action Cableのテストをallow_failuresから削除しています。

Wait for EventMachine to finish startingの対応でテストが安定したようだから、ですかねえ。


Remove case macro from calculate_constructable

activerecord/lib/active_record/reflection.rbの修正です。

AssociationReflection#calculate_constructableメソッドbelongs_tohas_one それぞれのassociationの場合の実装をまとめて行っていたのを、各子クラス(HasOneReflectionBelongsToReflection)でメソッドをオーバーライドし、それぞれのクラスで処理を行うよう修正しています。


Update Gemfile.lock

Gemfile.lockの修正です。

Drop the runtime dependency on coffee-railsでGemfileからcoffee-railsを削除したのですが、Gemfile.lockの更新が漏れていたので、追加で対応しています。


Merge pull request #23360 from kamipo/oid_money_precision_is_unused

activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rbactiverecord/lib/active_record/connection_adapters/postgresql_adapter.rbの修正です。

もう使用していないOID::Money.precision attributeを削除しています。


:speak_no_evil: :warning:

activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rbactiverecord/test/cases/adapters/sqlite3/sqlite3_adapter_test.rbの修正です。

composite primary keyのテストで、不要なwarningが出ないようsilence_warningsで囲むよう修正しています。


Merge pull request #23374 from prathamesh-sonpatki/migration-compatiblity-tests

activerecord/test/cases/migration/compatibility_test.rbの修正です。

古いmigrationファイルで、add_timestampsメソッドが生成するcreated_at / updated_atのデフォルトがnullで有ることを確認するテストを追加しています。


Merge pull request #23372 from kamipo/use_index_in_create_in_test_schema

activerecord/test/schema/mysql2_specific_schema.rbactiverecord/test/schema/schema.rbの修正です。

indexの定義にadd_indexメソッドを使用していたのを、TableDefinition#indexメソッドを使用するよう修正しています。

-  create_table :key_tests, force: true, :options => 'ENGINE=MyISAM' do |t|
+  create_table :key_tests, force: true, options: 'ENGINE=MyISAM' do |t|
     t.string :awesome
     t.string :pizza
     t.string :snacks
+    t.index :awesome, type: :fulltext, name: 'index_key_tests_on_awesome'
+    t.index :pizza, using: :btree, name: 'index_key_tests_on_pizza'
+    t.index :snacks, name: 'index_key_tests_on_snack'
   end

-  add_index :key_tests, :awesome, :type => :fulltext, :name => 'index_key_tests_on_awesome'
-  add_index :key_tests, :pizza, :using => :btree, :name => 'index_key_tests_on_pizza'
-  add_index :key_tests, :snacks, :name => 'index_key_tests_on_snack'

テストの起動を早める為、との事です。


Extract ExplainPrettyPrinter to appropriate files

Active Recordの修正です。

各adapter毎に異なる箇所で定義されていたExplainPrettyPrinterクラスを、adapter毎に別ファイルで(explain_pretty_printer.rb)定義するよう修正しています。


Remove duplicated composite primary key tests

Active Recordの修正です。

重複していたcomposite primary keyのテストを削除しています。


Revert "Merge pull request #23366 from maclover7/add-configuation-ar-docs"

rails guideのActive Record BasicsにDBへの接続の仕方を記載したConnecting to the Database節を追加した、Add configuration section to "Active Record Basics" guideをrevertしています。

guideにはRailsの基本的な使い方について書くべきだ、上記内容はそこから外れているのでは、という事でrevertされたようです。


Remove development dependencies from actioncable.gemspec

actioncable/actioncable.gemspecの修正です。

development dependencyからcoffee-scriptpg等を削除しています。

既に他のコンポーネントで使用しているgemであり、Action Cableで個別に定義する必要は無い為、削除したようです。


Merge pull request #23359 from kamipo/make_to_primary_key

activerecord/lib/active_record/internal_metadata.rbactiverecord/lib/active_record/schema_migration.rbの修正です。

internal tablesを作成する際、keyカラムにindexを設定したのを止めて、代わりにprimary keyの設定を行うよう修正しています。


Avoid extra show variables in migration

Active Recordの修正です。

MySQL adapterで、migratin実行の度にshow variablesが実行されてしまっていたのを、不要な場合は実行されないよう修正しています。

schema migratin tableの作成処理でchartsetを取得する為にshow variablesを実行しているのですが、既にschema migration tableが作成済みの場合もchartsetを取得しようとする処理になってしまっていたのが問題だったようです。tableが既にある場合はchartsetの取得処理は行わないよう修正しています。


Added references option to join tables

activerecord/lib/rails/generators/active_record/migration/templates/migration.rbの修正です。

join tableのmigrationを生成する際、association にreferencesオプションを指定出来るよう修正しています。

コミットログより。

bin/rails g migration CreateJoinTableShowroomUser showroom:references user:references
class CreateJoinTableShowroomUser < ActiveRecord::Migration[5.0]
  def change
    create_join_table :showrooms, :users do |t|
      t.references :showroom, foreign_key: true
      t.references :user, foreign_key: true
    end
  end
end

referencesオプションを指定しない場合、従来通りindexメソッドを使用したmigrationファイルが生成されます。

bin/rails g migration CreateJoinTableShowroomUser showroom user
class CreateJoinTableShowroomUser < ActiveRecord::Migration[5.0]
  def change
    create_join_table :showrooms, :users do |t|
      # t.index [:showroom_id, :user_id]
      # t.index [:user_id, :showroom_id]
    end
  end
end

indexだと別途外部キー制約しなくてはならなかったので、それをしないで済む分、便利そう。


tabenai (typo)

activerecord/test/cases/adapters/postgresql/extension_migration_test.rbの修正です。

変数名で、tabletabelにタイポしている箇所があったのを修正しています。


Fix documentation related to config.assets.cache_store [ci skip]

rails guideのThe Asset Pipeline、及びConfiguring Rails Applicationsの修正です。

最新のsprocketsでは、assetsのcache storeをconfig.assets.cache_store経由では設定出来なくなっているので、config.assets.cache_storeに関する説明を削除、代わりにconfig.assets.configure経由で値を設定する必要があるので、その例を追加しています。

config.assets.configure do |env|
  env.cache = ActiveSupport::Cache.lookup_store(:memory_store, { size: 32.megabytes })
end