なるようになるブログ

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

rails commit log流し読み(2017/08/15)

2017/08/15分のコミットです。

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

railties/CHANGELOG.md

activerecord/CHANGELOG.md


Railties updates for frozen string literals.

railtiesの修正です。

frozen_string_literalを指定した場合にエラーにならないよう、Stringを変更する箇所でdupを呼び出す等修正しています。


Adding frozen_string_literal pragma to Railties.

railtiesの修正です。

各ファイルの先頭にfrozen_string_literal: trueを指定するよう修正しています。


Run Active Storage service tests in CI

.travis.ymlの修正です。

Active Storageのserive testがCIで実行されるよう、AWS, GCP及びAzureアカウントの情報をCIで使えるよう設定を行っています。


Add frozen string pragma to expected routes files.

railties/test/generators/actions_test.rbの修正です。

テスト内で使う為のroutesにfrozen_string_literal: trueを指定するよう修正しています。


Allow for frozen string pragma in generated files.

railties/test/isolation/abstract_unit.rbの修正です。

frozen_string_literal: trueを指定する事により、テスト用データを追加する行数がずれてしまった箇所があったのを修正しています。


Merge pull request #29994 from y-yagi/fix_test_runner_help

railtiesの修正です。

test runnerのhelpにminitest、及び、その他pluginのオプションが表示されなくなってしまっていたのを、再度表示されるよう修正しています。


Merge pull request #30206 from yukihirop/improve_activerecord_rdoc

activerecord/RUNNING_UNIT_TESTS.rdocの修正です。

テスト対象のadapterを指定 + テストを一つだけ実行する場合の実行方法を追加しています。


Merge pull request #30241 from yhirano55/optimize_routes_indentation

railtiesの修正です。

generatorで生成するroutesファイルのインデントがずれる場合があったのを調整、及び、namespace + 複数アクションをgeneratorに指定した場合、namespaceが別々に定義されてしまっていたのを一つにマージするよう修正しています。

bin/rails g controller foo/bar/baz index show

上記コマンドを実行した場合に、

# config/routes.rb
namespace :foo do
  namespace :bar do
    get 'baz/index'
    get 'baz/show'
  end
end

というようにroutesが生成されるよう修正しています。


Merge pull request #30239 from bogdanvlviv/improve-plugin_generator_code

railties/lib/rails/generators/rails/plugin/plugin_generator.rbの修正です。

plugin generatorに渡すオプションの一覧にapiオプションを渡すよう修正、及び、不要なforceオプションは渡さないよう修正しています。


Merge pull request #30235 from bogdanvlviv/omit-additional-removing-cable_yml

railties/lib/rails/generators/rails/app/app_generator.rbの修正です。

不要なconfig/cable.ymlの削除処理を削除しています。skip_action_cableオプションを指定した場合、そもそも左記ファイルは作成されない為。


Merge pull request #30233 from kamipo/remove_duplicated_join_id_for

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

BelongsToReflection#join_id_for及びThroughReflection#join_id_forメソッドを削除しています。親クラスのjoin_id_forメソッドを使用すれば良い為。


Merge pull request #30244 from yhirano55/refactor_max_age_seconds

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttrailties/lib/rails/generators/rails/app/templates/config/environments/test.rb.ttの修正です。

Cache-Controlmax-ageの指定例から、不要なsecondsの呼び出しを削除しています。

-      'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}"
+      'Cache-Control' => "public, max-age=#{2.days.to_i}"

Durationクラスのto_iは必ず秒の値を返す為。


Merge pull request #30231 from kamipo/remove_unused_source_type_info

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

使用していないRuntimeReflection#source_type_infoメソッドを削除しています。


Move test to its proper place

Active Storageのテストの修正です。

activestorage/test/filename_test.rbactivestorage/test/models/filename_test.rbに移動しています。ActiveStorage::Filenameはmodelの為。


Fix asset pipeline guide [skip ci]

rails guideのThe Asset Pipelineの修正です。

Rails.application.config.assets.pathsを指定するexampleがconfig/application.rbに指定するよになっていたのを、現行のコードと同じように、config/initializers/assets.rbに指定するよう修正しています。


Fix guide about command_line [ci skip]

rails guideのThe Rails Command Lineの修正です。

bin/rails generateコマンドのexampleに不足していたchannelを追加、及び、scaffoldのexampleに不足していたsystem testのファイル生成例を追加しています。


Merge pull request #30236 from padi/find-each-example-update

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

ActiveRecord::Batches.find_eachメソッドのdocのexampleにfinishオプションを指定した場合のexampleを追加しています。


Merge pull request #30214 from kirs/uniqueness-scope-validator

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

validates_uniqueness_ofscopeオプションに不正な値(Symbol又はSymbolのArray以外の値)を指定した場合に、ArgumentErrorをraiseするよう修正しています。


Merge pull request #30229 from kamipo/allow_serialize_with_custom_coder

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

json及びarrayカラムをserializeする際に、任意のcoderを使用出来るよう修正しています。

hstoreカラムでは任意のcoderを使用出来るよになっており、それに合わせる為対応したようです。


Merge pull request #27609 from kamipo/fix_association_primary_key

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

has_many associationにprimary_keyオプションを指定している場合に、collection_singular_idsメソッドがエラーになってしまう(primary_keyオプションで指定した値を正しく扱っていない)バグがあったのを修正しています。


Merge pull request #30208 from kamipo/extract_primary_key_to_abstract_reflection

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

AssociationReflectionクラス、HasManyReflectionクラスそれぞれで同じ内容のprimary_keyメソッドを定義していたのを、親クラスのAbstractReflectionでメソッドを定義し、子クラスからはメソッドを削除するよう修正しています。


Merge pull request #30219 from yhirano55/fix_app_generator_api_options

railtiesの修正です。

rails new--apiオプションを指定した場合のテストのリファクタとして、重複していたテストを削除、テスト対象のファイル名をタイポしていたのを修正等を行っています。


Merge pull request #30073 from yalab/fixture_binary_helper

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

binaryファイルを読み込む為のbinaryメソッドをfixtureで使用出来るよう修正しています。

実装は下記のような感じ。

def binary(path)
  %(!!binary "#{Base64.strict_encode64(File.read(path))}")
end

Merge pull request #30215 from untidy-hair/clarify-abstract-or-not-in-tests

activerecord/test/cases/associations/join_model_test.rbactiverecord/test/cases/inheritance_test.rbの修正です。

STIを使用しているabstractクラスの子クラスのクラスが正しく動作する事を確認するテストを追加しています。


Merge pull request #30169 from awortham/awortham/awortham/fix-sql-distinct-bug

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

has_many :through associationに対して、distinctを指定したsumメソッドが正しく動作しないバグがあったのを修正しています。


Fix format of generator docs [ci skip]

railties/lib/rails/generators/actions.rbのdocの修正です。

Generators::Actions#libメソッドのdoc内のlibディレクトリをタイプライター体で表示されるようttタグを追加しています


Formatting CHANGELOGs [ci skip]

activerecord/CHANGELOG.mdrailties/CHANGELOG.mdの修正です。

各エントリーのフォーマットの修正を行っています。


Fix typo for api_app_generator_test

railties/test/generators/api_app_generator_test.rbの修正です。

test_api_modified_filesassetsassertsにタイポしていたのを修正しています。