なるようになるブログ

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

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

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

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

actionpack/CHANGELOG.md


Add headless firefox driver to System Tests

actionpack/lib/action_dispatch/system_test_case.rbactionpack/lib/action_dispatch/system_testing/driver.rbの修正です。

System Testsにheadless firefoxのサポートを追加しています。

driven_byheadless_firefoxを指定(e.g. driven_by :selenium, using: :headless_firefox)すれば使用出来るようになっています。


Fix scope_for_create to do not lose polymorphic associations

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

polymorphic associationをcreateするした際に、scopeで指定したpolymorphicの指定が失われしまうバグがあったのを修正しています。


Fix customizing Content-Type via GCS service URLs

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

GCS serviceでファイルをアップロードする際に、明示的にcontent typeにnilを指定するよう修正しています。

-          bucket.create_file(io, key, md5: checksum)
+          # The official GCS client library doesn't allow us to create a file with no Content-Type metadata.
+          # We need the file we create to have no Content-Type so we can control it via the response-content-type
+          # param in signed URLs. Workaround: let the GCS client create the file with an inferred
+          # Content-Type (usually "application/octet-stream") then clear it.
+          bucket.create_file(io, key, md5: checksum).update do |file|
+            file.content_type = nil
+          end

GCS client libraryはデフォルトでcontent typeを設定するようになっているのですが、それが設定された状態だと、本来指定したいcontent type(signed URLsのparamに指定したresponse-content-type)が指定されない為、デフォルトの値がclearする事で対処した、との事です。


Merge pull request #30780 from JackMc/fix-chrome-referrer-invalidauthenticitytoken

actionpack/lib/action_controller/metal/request_forgery_protection.rbの修正です。

authenticity tokenのチェックの際に、request originがnullの場合、その旨エラーメッセージを返すよう修正しています。

Chromeが、referrer policy headerにno-referrerが指定されている場合にnullを返すようにした為、それがわかるよう明示的なエラーメッセージを返すようにしたとの事です。


SQLite: Fix copy_table with composite primary keys

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

DBにsqliteを使用している場合にprimary keyにid以外のtypeを指定しているtableに対してchange_tableを実行するとエラーになるバグを対応した、Merge pull request #31327 from aellispierce/custom-id-change-table-sqliteで、primary keyがcomposite primary keyだった場合の対応が含まれていなかったので、追加で対応しています。