なるようになるブログ

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

rails commit log流し読み(2018/06/28)

2018/06/28分のコミットです。

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

activemodel/CHANGELOG.md


Merge pull request #33217 from eugeneius/test_duration_preserve_parts

activesupport/test/core_ext/duration_test.rbの修正です。

Durationの乗算、除算についてのテストを追加しています。


Fix ActionMailer assert_enqueued_email_with

activejob/lib/active_job/test_helper.rbの修正です。

assert_enqueued_withメソッドでblockが指定された時だけyieldを実行するよう修正しています。

assert_enqueued_withメソッドはassert_enqueued_email_withから呼ばれるのですが、assert_enqueued_email_withメソッドはblockを指定しないでも動作する旨docにて記載されていました。

しかし実際はassert_enqueued_withのyield実行時エラーになってしまっていたので、docの説明の通り、assert_enqueued_email_withにblockを指定しなかった場合にも動作するよう、修正を行っています。

が、これはdocが誤りで、blockは必ず指定する必要がある(blockの指定が無いと、assertionが必ず失敗する)為、後ほどrevertされています。


Break guides menu 'Digging Deeper' section in two

guides/source/documents.yamlの修正です。

Digging Deeperセクション配下にあったコンテンツのうち、コンポーネントに関するコンテンツを新規に追加したOther Componentsセクション配下に移動しています。


Merge pull request #26764 from choncou/improve_has_secure_password

activemodel/lib/active_model/secure_password.rbの修正です。

has_secure_passwordメソッドが定義するattribute名をオプションで指定出来るよう修正しています。

class User < ActiveRecord::Base
    has_secure_password :activation_token, validations: false
end

user = User.new
user.activation_token = "a_new_token"
user.activation_token_digest                        # => "$2a$10$0Budk0Fi/k2CDm2PEwa3Be..."
user.authenticate_activation_token("a_new_token")   # => user

Improve wording for form_with in Getting Started Guide

rails guideのGetting Started with Railsの修正です。

Updating Articlesの項、form_withについて説明している箇所の言い回しを修正しています。


Revert "Merge pull request #33243 from evopark/fix/action-mailer-test-helper-no-block"

assert_enqueued_withメソッドでblockが指定された時だけyieldを実行するよう修正した、Fix ActionMailer assert_enqueued_email_withをrevertしています。理由は上記参照。

rails commit log流し読み(2018/06/27)

2018/06/27分のコミットです。

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


Call initialize after allocate

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

ActiveRecord::Core#allocateメソッドを削除しています。

元々define_attribute_methodsメソッドを呼び出ていただけで、初期化処理全て行っていたわけではない、かつ、instantiateメソッド等を経由してオブジェクトを生成した場合、define_attribute_methodsメソッドが2回呼ばれてしまう、という問題もあった為、削除しています。


Merge pull request #33223 from rails/homogeneous-allocation

Active Recordの修正です。

Active Recordのオブジェクトの初期化前に、STI用のカラムが含まれているかチェックし、含まれていない場合、不要なクラスの初期化処理を行わないよう(作成済みのデータを使い回す)修正しています。これにより、オブジェクトの生成処理が減少し、結果処理性能が改善しています。


Add changelog entry for 3110cae [ci skip]

activejob/CHANGELOG.mdの修正です。

retry_ondiscard_onメソッドに複数のExceptionを指定出来るよう修正した、Allow passing multiple exceptions to retry_on/discard_onの対応についてCHANGELOGにエントリーを追加しています。


Merge pull request #33234 from alpaca-tc/autoload_activejob_arguments

Active Jobの修正です。

明示的にrequireせずに使えるようにする為に、ActiveJob::Argumentsをautoloadするよう修正しています。

rails commit log流し読み(2018/06/26)

2018/06/26分のコミットです。

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


Use reflection.alias_candidate in table_alias_for

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

JoinDependency::Aliases#table_alias_forメソッドでaliasを生成する際に、独自に文字列を生成していたのを、reflection.alias_candidateメソッドを使用するよう修正しています。


references(:developers_projects_join) isn't needed if using where with hash condition

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

joinのテストから不要なreferencesの呼び出しを削除しています。


Lazily add Aggregations to composed_of models

activerecord/lib/active_record/aggregations.rbactiverecord/lib/active_record/base.rbの修正です。

ActiveRecord::BaseAggregations moduleをincludeしていたのを、composed_ofメソッド呼び出し時にAggregations moduleをincludeするよう修正しています。

Aggregations moduleはcomposed_ofを使用するときだけ必要、かつ、composed_ofメソッドを使用するのはかなりまれ、かつ、Aggregations moduleをincludeするとcomposed_ofメソッドを使用しない場合には不要なaggregation_cache hashが必ず生成されてしまう為、不要なオブジェクトの生成を減らせるようする為に上記修正を行っています。


Allow passing multiple exceptions to retry_on/discard_on

activejob/lib/active_job/exceptions.rbの修正です。

retry_ondiscard_onメソッドに複数のExceptionを指定出来るよう修正しています。


Generate a new key for each service test

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

各serviceのテストで使用するkeyに固定の値を使用していたのを、テスト毎にkeyを生成するよう修正しています。

同じkeyを使いまわすと、Google Cloud Storageの制限(Google::Cloud::ResourceExhaustedError: rateLimitExceeded: The total number of changes to the object rails-ci-activestorage/xx exceeds the rate limit. Please reduce the rate of create, update, and delete requests.)に引っかかってしまう事がある為。


Add example for no_touching? in active_record/no_touching for api docs [ci skip]

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

ActiveRecord::NoTouching#no_touching?にdocを追加しています。


Remove ActiveSupport::Concern from ActiveRecord::Aggregations

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

Lazily add Aggregations to composed_of modelsの対応により不要になったActiveSupport::Concernのextendを削除しています。


Enable TESTOPTS in railties tests

railties/Rakefileの修正です。

railtiesのテストでテスト実行時に指定したTESTOPTSが有効になるよう修正しています。

rails commit log流し読み(2018/06/25)

2018/06/25分のコミットです。

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


Merge pull request #33191 from bogdanvlviv/change-rails_welcome-image-on-localhost3000

railties/lib/rails/templates/rails/welcome/index.html.erbの修正です。

welcomeページで表示される画像を、guideで表示されているのと同じ画像(Update 'rails_welcome.png' to reflect a more diverse populationで更新された画像)を使用するよう修正しています。


Revert "Avoid Node.js v10.4.0 for now"

CIで使用するNode.jsのバージョンをv10.4.0に固定した、Avoid Node.js v10.4.0 for nowをrevertしています。

Node.js v10.5.0がリリース済み、かつ、10.5.0でrails-ujsのbuildが壊れる、という問題がfix済みのため。

rails commit log流し読み(2018/06/24)

2018/06/24分のコミットです。

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


Update raabro to latest version

Gemfile.lockの修正です。

raabroのバージョンを最新のバージョンに更新しています。


Fix formatting of primary_key [ci skip]

activerecord/lib/active_record/connection_adapters/postgresql/schema_definitions.rbのdocの修正です。

primary_keyメソッドのdocのフォーマットを修正しています。


Update service.rb

activestorage/lib/active_storage/service.rbのdocの修正です。

ActiveStorage::Service#urlメソッドのdocのグラマーの修正を行っています。


Add an assertion that credentials:edit works when RAILS_MASTER_KEY env is specified

railties/test/commands/credentials_test.rbの修正です。

config/master.keyがない、かつ、RAILS_MASTER_KEY envが指定されている場合に、credentials:editコマンドが正しく動作することを確認するassertを追加しています。

rails commit log流し読み(2018/06/23)

2018/06/23分のコミットです。

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


Active Storage: Explicit form field in basic example

rails guideのActive Storage Overviewの修正です。

has_one_attachedの項、attachmentを更新するexampleコードについて説明している箇所に、viewのコードも追加しています。


OS X -> macOS [Closes #30313]

各ドキュメント内で、OS Xになっていた箇所をまとめてmacOSに修正しています。

rails commit log流し読み(2018/06/22)

2018/06/22分のコミットです。

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


Permit configuring the default service URL expiry

Active Storageの修正です。

Active Storageが生成するファイルアクセス用のURLの有効期限が5分固定になっていたのを、configで有効期限を指定出来るよう修正しています。

値はconfig.active_storage.service_urls_expire_inで指定出来るようになっています。


Add missing test case for find with a large number

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

findメソッドに巨大な数字を指定した場合のテストを追加しています。


Add to docs mention about :year_format option of date select

actionview/lib/action_view/helpers/date_helper.rbのdocの修正です。

date_selectメソッドのdocに:year_formatオプションについての説明を追加しています。