なるようになるブログ

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

rails commit log流し読み(2017/06/12)

2017/06/12分のコミットです。

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

activesupport/CHANGELOG.md


Merge pull request #29263 from assain/default_message_encryptor_to_gcm

Active Supportの修正です。

ActiveSupport::MessageEncryptorのデフォルトのcipherにAES 256 GCMを使用するよう修正しています。


[ci skip] Add changelog entry for 6d402c6

activesupport/CHANGELOG.mdの修正です。

先のActiveSupport::MessageEncryptorの対応について、CHANGELOGにエントリーを記載しています。


Fix Message::Encryptor default cipher [ci skip]

activesupport/lib/active_support/message_encryptor.rbのdocの修正です。

MessageEncryptorクラスのdoc内のcipherのデフォルト値の説明に誤りがあったのを修正しています。


Drop IRB out of the web-console Gemfile comment

railties/lib/rails/generators/rails/app/templates/Gemfileの修正です。

web-console gemについての説明から、IRBという単語を削除しています。

-  # Access an IRB console on exception pages or by using <%%= console %> anywhere in the code.
+  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.

web-consoleIRBと同じ動作を提供しているわけではないため。


Add brakeman to guides/additional resources. Fixes #29383 [ci skip] (#29427)

rails guideのRuby on Rails Security Guideの修正です。

Additional Resourcesの項にBrakeman - Rails Security Scannerへのリンクを追加しています。


Add note to Railtie docs to use unique filenames

railties/lib/rails/railtie.rbの修正です。

Rails::Railtieクラスのdoc内のLoading Rake Tasks and Generatorsの項に、taskやgeneratorのファイル名は、複数gem間でユニークである必要がある旨説明を追加しています。

rails commit log流し読み(2017/06/11)

2017/06/11分のコミットです。

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

actionview/CHANGELOG.md


Revert #25628. Incomplete change + needs a deprecation cycle.

ActiveSupport::Cache::Strategy::LocalCache::LocalStore#clear、及び、ActiveSupport::Cache::Strategy::LocalCache#clearから使用していないoptions引数を削除した、Merge pull request #25628 from ysksn/optionsをrevertしています。

対応が不完全だったのと、optionsはdocにのっている情報だったので、使ってなかったとしてもまずdeprecation cycleを実施すべきだから、というのが理由のようです。


Cache: test coverage for cleanup behavior with local cache strategy

activesupport/lib/active_support/cache/strategy/local_cache.rbactivesupport/test/cache/behaviors/local_cache_behavior.rbの修正です。

local cacheをcleanupした場合のテストを追加しています。


Access EDITOR through Ruby’s cross-platform ENV.

railties/lib/rails/commands/secrets/secrets_command.rbの修正です。

secrets:editコマンドでEDITORを指定する際に、ENVハッシュ経由で値を取得するよう修正しています。Windows環境でも動作するようにする為との事です。


Document Module#delegate_missing_to in the guides

rails guideのActive Support Core Extensionsの修正です。

delegate_missing_toメソッドについての説明を追加しています。


Missing dots [ci skip] (#29414)

rails guideのActive Support Core Extensionsの修正です。

文末にドットが不足していた箇所に追加しています。


Merge pull request #29412 from y-yagi/fix_29014

actionview/lib/action_view/helpers/tags/collection_check_boxes.rbactionview/lib/action_view/helpers/tags/collection_radio_buttons.rbの修正です。

form_with配下でcollection_check_boxescollection_radio_buttonsを使用した際にinputタグにid属性が生成されていなかったのを、id属性が生成されるよう修正しています。

collection_check_boxescollection_radio_buttonsinputタグとlabelタグ両方生成するのですが、id属性が無いとinputタグとlabelタグが紐付けられない為。

rails commit log流し読み(2017/06/10)

2017/06/10分のコミットです。

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


[ci skip] Add backquote to :counter_cache option

rails guideのActive Record Associationsの修正です。

:counter_cacheをバッククォートで囲むよう修正しています。


Split up the cache test suite so it’s easier to understand and extend (#29404)

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

test/caching_test.rbに全てのcacheに関するテストが記載されていたのを、機能ごとにファイルを分けるよう修正しています。


Remove null_allowed option from doc [ci skip]

activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rbのdocの修正です。

add_columnメソッドのdocに存在しないnull_allowedオプションについての説明があったのを削除しています。

rails commit log流し読み(2017/06/09)

2017/06/09分のコミットです。

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


Merge pull request https://github.com/rails/rails/pull/28637 from st0012/fix-partial-cache-logging

Action Viewの修正です。

partial templateがcacheされていないのにログにcache hitと表示される(またはその逆)バグがあったのを修正しています。


Don’t rely on the @view_renderer being defined.

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

fragment_forメソッドで@view_renderer変数を参照する前に、@view_rendererが定義済みかどうかチェックするよう修正しています。Action Mailerからの処理だと定義されていない事がある為。


Fix link in active_record_postgresql.md

rails guideのActive Record and PostgreSQLの修正です。

PostgreSQLの公式ドキュメント(functions and operators)へのリンクが誤っていたのを修正しています。


remove the extra comma in association_basics.md

rails guideのActive Record Associationsの修正です。

limitメソッドのexmapleコードに不要なカンマがあったのを削除しています。


[ci skip] Fix link in active_record_postgresql.md

rails guideのActive Record and PostgreSQLの修正です。

PostgreSQLの公式ドキュメント(pgcrypto generator function)へのリンクが誤っていたのを修正しています。


Merge pull request #29361 from metaskills/sqlserversetup-take2

railties/lib/rails/generators/rails/app/templates/config/databases/sqlserver.ymlの修正です。

ENV varの指定方法に誤りがあったのを修正しています。


Make i18n test match the description of the test

railties/test/application/initializers/i18n_test.rbの修正です。

i18n.fallbacksのテストで、テストのdescriptionと実際にテストしている内容が食い違っていたのを修正しています。

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

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

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


Move slicing to initializer.

actionview/lib/action_view/helpers/tags/base.rbactionview/lib/action_view/helpers/tags/select.rbの修正です。

selectタグから不要なオプションを除去する処理を、select_content_tagメソッドで行っていたのをTags::Selectクラスの初期化処理で行うよう修正しています。


Don’t support namespace in form_with.

actionview/test/template/form_helper/form_with_test.rbの修正です。

form_withnamespaceオプションを指定した場合のテスト(skipが設定されており動かなかったテスト)を削除しています。form_withではidをユーザが明示的に指定する必要があり、namespaceが必要ならそちらも合わせて明示的に指定すれば良いため、との事です。


Remove unreachable code

activesupport/lib/active_support/railtie.rbの修正です。

実行される事の無いconfig.time_zoneに不正な値が指定された場合の処理を削除しています。


Bundle capybara 2.14.1 that includes fix for Ruby warnings

Gemfile.lockの修正です

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

rails commit log流し読み(2017/06/07)

2017/06/07分のコミットです。

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

activesupport/CHANGELOG.md


Tiny documentation fixes [ci skip]

actionpack/lib/action_dispatch/system_test_case.rbのdoc、及び、rails guideのA Guide to Testing Rails Applicationsの修正です。

ActionDispatch::SystemTestCaseのdoc及びguideのSystem Testingの項のグラマー、フォーマットの修正を行っています。


Remove invalid entry from the guides index page

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

Remove obsolete Guides source files [ci skip] · rails/rails@1a5d939で削除されたProfiling Rails Applicationsがインデックスページに残っていたのを削除しています。


Update upgrading guide w.r.t. Parameters to use other example method than slice as this has actually been implemented by Parameters https://github.com/rails/rails/commit/f59559d70af237f8a52e4ebde34b39d834f2787e

rails guideのA Guide for Upgrading Ruby on Railsの修正です。

ActionController::Parameters No Longer Inherits from HashWithIndifferentAccess"の項で、permitted?に依存しないメソッドの例でsliceがあげられていたのですが、sliceActionController::Parametersに実装されており問題無い為、例のメソッドをmapに変更しています。


Cache: write_multi (#29366)

activesupport/lib/active_support/cache.rbの修正です。

ActiveSupport::Cache::Storewrite_multiメソッドを追加しています。名前の通りで複数データをまとめて書き込む為のメソッドです。

Rails.cache.write_multi foo: 'bar', baz: 'qux'

実際の書き込み処理はwrite_multi_entriesメソッドを使用するようになっており、fetch_multiでデータを書き込む場合(fetch出来なかった場合)もこちらのメソッドを使用するようになっています。write_multi_entriesの実装はwrite_entryを複数回呼び出すだけになっており、基本的には各storeクラスでオーバライドする事を想定しているとの事です(Redisの場合はMSETを使うようにする等)。

rails commit log流し読み(2017/06/06)

2017/06/06分のコミットです。

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


Remove deprecated passing of string to :if/:unless (#29357)

rails guideのActive Record Validationsの修正です。

Combining Validation Conditionsの項に、deprecatedになっていたifオプションにStringを渡すexampleがあったのを修正しています。


[ci skip] UNIQUE constraint affects not only INSERT but also UPDATE

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

RecordNotUniqueのdocにINSERT処理でユニーク制約に違反した場合にraiseされる旨説明がされていたのですが、実際はUPDATEでも発生する可能性はある為、その旨説明を修正しています。


Fix indentation + Add backticks [ci skip]

activesupport/CHANGELOG.mdの修正です。

インデントの修正及びメソッド名をバッククォートで囲むよう修正しています。


Remove html tag making markdown misrender [ci skip]

CONTRIBUTING.mdの修正です。

不要なbrタグがあったのを削除しています。


Let’s test nokogiri 1.8 against edge Rails, and vice versa

Gemfile.lockの修正です。

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


Fix test_pluck_without_column_names when using Oracle

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

pluckカラム名を指定しない場合のテストがOracle adapterで失敗していたのを修正しています。

-    assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, ""]],
-      Company.order(:id).limit(1).pluck
+    if current_adapter?(:OracleAdapter)
+      assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, nil]], Company.order(:id).limit(1).pluck
+    else
+      assert_equal [[1, "Firm", 1, nil, "37signals", nil, 1, nil, ""]], Company.order(:id).limit(1).pluck
+    end

上記テストはデフォルトに空文字を指定したschemaを使用しているのですが、Oracleは空文字とNULを区別しない為、空文字ではなくNULLを返ってくる為上記のような分岐処理を追加し対応したとの事です。


PostgreSQL 10 converts unknown OID 705 to text 25

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

PostgreSQLで認識できないtypeが指定された場合のテストで、存在しない要素をSELECTに指定していたのを、pg_catalog.pg_class'::regclassを使用するよう修正しています。

-            @connection.select_all "SELECT NULL::anyelement"
+            @connection.select_all "select 'pg_catalog.pg_class'::regclass"

PostgreSQL 10までは上記テストが通っていたのですが、PostgreSQL 10で認識できないOIDの場合にftype 25(typename: text)を返すようになってしまった為、元のテストでは通らなくなってしまった為pg_classを使用するよう修正したようです。

参考:Re: ‘text’ instead of ‘unknown’ in Postgres 10


Merge pull request #29362 from kamipo/remove_redundant_assert_nothing_raised

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

本来テストを行いたい箇所とは別な箇所でassert_nothing_raisedを使用していたのを削除しています。