なるようになるブログ

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

rails commit log流し読み(2020/10/10)

2020/10/10分のコミットです。

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


Update action_text_overview.md

rails guideのAction Text Overviewの修正です。

Avoid N+1 queriesの項のexampleの前に、exampleで使われているscopeはどのようなfield nameの場合に生成されるscopeなのかの説明を追加しています。


Fixes case in guides title [skip ci]

rails guideのAutoloading and Reloading Constants (Zeitwerk Mode)の修正です。

ガイドのタイトル名に大文字を使用するよう修正しています。


documents differences zeitwerk vs classic mode [skip ci]

rails guideのAutoloading and Reloading Constants (Zeitwerk Mode)の修正です。

zeitwerkとclassic modeの違いについて説明したDifferences with Classic Modeセクションを追加しています。


edits in the constants guide [skip ci]

rails guideのAutoloading and Reloading Constants (Zeitwerk Mode)の修正です。

各箇所の言い回しを修正しています。


Merge pull request #39784 from marcrohloff/remove-magic-parameter-from-where

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

Relation#whereの引数から不要な引数を削除しています。

rails commit log流し読み(2020/10/09)

2020/10/09分のコミットです。

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


Rework Date and Time Form Helpers section [ci-skip]

rails guideのAction View Form Helpersの修正です。

Using Date and Time Form Helpersセクションについて、素のselect helpersについてメインで説明していたのを、form builderのselect helperについてをメインで説明するよう修正しています。


Merge pull request #38443 from jonathanhefner/plugin-fix-stack-traces

railtiesの修正です。

rails pluginのテストを実行した場合に、テスト失敗時にstack traceが正しく表示されない事があったのを修正しています。

rails commit log流し読み(2020/10/08)

2020/10/08分のコミットです。

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


Raise more specific exception for invalid mime type from user-agent

Action Packの修正です。

clientから送信されたmimeが不正だった場合にraiseするexceptionをMime::Type::InvalidMimeTypeから、独自のエラー(ActionDispatch::Http::MimeNegotiation::InvalidType)に修正しています。

不正なmimeが送信された事によるエラーなのか、その他違う処理で発生したエラーなのかを区別出来るようにする為。


Prevent XSS in the Actionable Exceptions middleware

actionpack/lib/action_dispatch/middleware/actionable_exceptions.rbの修正です。

不正なURLが送信された場合に、Actionable Exceptions middlewareでXSS出来てしまう脆弱性があったのを修正しています。

参考: [CVE-2020-8264] Possible XSS Vulnerability in Action Pack in Development Mode


Don't log backtrace for ActionDispatch::Http::MimeNegotiation::InvalidType

actionpack/lib/action_dispatch/middleware/exception_wrapper.rbの修正です。

ActionDispatch::Http::MimeNegotiation::InvalidTypeが発生した場合、frameworkのtraceはログに出力されないよう修正しています。


Fix style of this file

actionpack/lib/action_dispatch/middleware/actionable_exceptions.rbの修正です。

rubocopの設定に違反している箇所があったのを修正しています。


Add missing space before closing hash brace

actionpack/lib/action_dispatch/middleware/actionable_exceptions.rbの修正です。

rubocopの設定に違反している箇所があったのを修正しています。


Fix pending migration actionable error test

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

Prevent XSS in the Actionable Exceptions middlewareの修正の影響で、既存のテストが通らなくなっていたのを修正しています。


Prefix keys in Active Storage service test

activestorage/test/service/shared_service_tests.rbの修正です。

prefixを指定した場合のテストで、prefixにランダムな値を追加するよう修正しています。同時にテストが実行された場合にも通るようにする為。

rails commit log流し読み(2020/10/07)

2020/10/07分のコミットです。

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

actionpack/CHANGELOG.md


Link API documentation more in Form Helpers guide [ci-skip]

rails guideのAction View Form Helpersの修正です。

各メソッドからAPI docにリンクを貼るよう修正しています。


Do not add newlines when annotating rendered views

actionview/lib/action_view/template.rbactionview/lib/action_view/template/handlers/erb.rbの修正です。

rendered viewsのannotating処理でBEGIN / ENDコメントの後に改行を入れていたのを、入れないよう修正しています。

見やすくする為に改行を入れていたのですが、templateをrenderした結果をStringとして扱うような場合に邪魔になってしまう事がある為、改行は入れないよう修正しています。


Fix ActiveRecord::Relation#include? in case where offset is provided

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

loadされてないrelationに対してActiveRecord::Relation#include?を offset付きで実行した場合に、offsetが無視されてしまうバグがあったのを修正しています。


Add back missing LIMIT 1 in find_by SQL example [ci skip]

rails guideのActive Record Query Interfaceの修正です。

find_byで実行されるSQLのexampleが実際の内容と異なっていたのを修正しています。


Handle Relations with limit in include?

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

loadされてないrelationに対してActiveRecord::Relation#include?を limit付きで実行した場合に、limitが無視されてしまうバグがあったのを修正しています。


Revert "Merge pull request #39304 from zenspider/zenspider/backtrace_filter_should_never_return_empty"

BacktraceCleanerが空のbacktraceを返さないよう修正した、Fixed BacktraceCleaner to never return an empty backtrace.をRevertしています。

Railsのbacktrace cleanerは空のbacktraceを返せるようにする必要がある(アプリケーションコードとフレームワークコードを分ける為)為。


Decorate Rails' backtrace cleaner before passing to minitest

railties/lib/minitest/rails_plugin.rbの修正です。

minitestにbacktrace cleanerを渡す際に、空のbacktraceを返せるよう処理を定義したdecoratorでラップしたbacktrace clearを渡すよう修正しています。


Document new Record Active Support hooks

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

Extract ActiveStorage::RecordExtract ActionText::RecordExtract ActionMailbox::Recordで追加されたhook(action_mailbox_recordaction_text_recordactive_storage_record)をhookの一覧に追加しています。


attr_reader methods are public methods

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

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


Get rid of unnecessary meta programming

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

middlewareのメソッドを呼び出す処理から不要なメタプロを削除しています。


This kind of wrapper should better not be able to call private methods railties/lib/rails/engine/updater.rbの修正です。

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


Both update_config_files and update_bin_files are public methods

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

publicメソッドを呼び出すのにsendを使用していたのを、直接メソッドを呼び出すよう修正しています。


If it respond_to a method, the method should be public_sendable

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

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


allow for only no-store in cache-control header

actionpack/lib/action_dispatch/http/cache.rbの修正です。

Cache-Control headerにno-storeだけを指定出来る(privateの指定も無し)よう修正しています。


Given method here (e.g. perform) should be public_sendable

activejob/test/support/queue_classic/inline.rbの修正です。

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


URL helper methods are public methods

actionpack/lib/action_dispatch/routing/mapper.rbの修正です。

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。

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

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

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


Ensure tag.with_options({}).p builds a <p>

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

tag builderで with_options + pを指定した場合に<p>タグが生成出来ずエラーになってしまうバグがあったのを修正しています。


Wording in guides: Prefer environment over mode

各guideの修正です。

environmentについて説明している箇所で、説明でmodeを使用していた箇所を、全てenvironmentに修正しています。


Accessors here are public

actionmailer/test/base_test.rbの修正です。

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


Routes methods are public methods

actionpack/lib/action_dispatch/routing/polymorphic_routes.rbの修正です。

public methodsを呼び出すのにsendを使用していたのを、public_sendを使用するよう修正しています。


Module#include is a public method since Ruby 2.1

activestorage/test/test_helper.rbの修正です。

public methodであるModule#includeを使用するのにsendを使用していたのを、メソッドを直接呼び出すよう修正しています。

rails commit log流し読み(2020/10/05)

2020/10/05分のコミットです。

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

activerecord/CHANGELOG.md


Add gitattributes for vendored and generated files [ci-skip]

vendored librariesとgenerated filesを格納しているディレクトリにgitattributesを追加しています。


Support passing record to uniqueness conditions

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

uniqueness validatorの:conditionsオプションにrecordを渡せるよう修正しています。recordのデータからconditionを指定出来るようにする為。

class Article < ApplicationRecord
  validates_uniqueness_of :title, conditions: ->(article) {
    published_at = article.published_at
    where(published_at: published_at.beginning_of_year..published_at.end_of_year)
  }
end

rails commit log流し読み(2020/10/04)

2020/10/04分のコミットです。

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

activerecord/CHANGELOG.md


Return rows affected from batched update_all and delete_all

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

BatchEnumerator#update_allBatchEnumerator#delete_allの戻り値を、処理が行われた行数を返すよう修正しています。


Merge pull request #40285 from tgxworld/fix_flaky_test

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

test_with_advisory_lock_closes_connectionで、実行するqueryをSELECT COUNT(*)からSELECT queryに修正しています。テストが失敗した際に、失敗した際の情報を取得出来るようにする為。


Merge pull request #39871 from p8/guides/copy-code-examples

rails guideの修正です。

guide内のexampleコードに、コードをコピーする為のCopyボタンを追加しています。

94718668-5993eb80-0352-11eb-97cc-14f1ab9a90f6.png (944×228)


Update sidekiq to fix warnings in Active Job tests

Gemfile.lockの修正です。

sidekiqのバージョンを最新のバージョンに更新しています。redis gemのwarningが表示されないようにする為。


Update sprockets-rails to fix tests on Ruby master

Gemfile.lockの修正です。

sprockets-railsのバージョンを最新のバージョンに更新しています。Ruby masterとのテストが通るようにする為。


Avoid chdir error in Railties tests on Ruby master

railtiesのテストの修正です

Ruby masterで、Dir.chdirのblock内でblockを指定せずにDir.chdirを実行した場合にエラーになるように修正された影響でrailtiesのテストがエラーになっていたのを修正しています。

参考: Switch conflicting chdir warning to RuntimeError