なるようになるブログ

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

rails commit log流し読み(2014/08/04)

2014/08/04分のコミットです。

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

activerecord/CHANGELOG.md


Generating stubs for helper tests is overly specific. Most helpers should simply be tested as part of the view thats using them. If you need something beyond that, you can add a test yourself for them

generatorの修正です。

helperのテストファイル作成処理を削除しています。

殆どのhelperはviewのテストの一部分としてやってしまっているので、単体では不要なのでは、という事のようです。


Change the production log level default from :info to :debug. All production apps I have ever worked with has done this. Let us reflect that default. You often want those SQL quieries to be able to debug issues in production

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

productionのデフォルトのログレベルを:infoから:debugに変更しています。

DHH自身が、productionのデフォルトのログレベルをdebugにしていたから、との事です。


Stubs are no longer generated for helpers, so dont test for it

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

helperのテストファイル作成処理のテストを修正しています。


Update docs to reflect that helper stubs are no longer generated

rails guideの修正です。

helperのテストファイル作成処理削除に伴うrails guideの修正対応です。


A few more tests asserting the presence of helper test stubs

railtiesの修正です。

helperのテストファイル作成処理のテストの修正の続きです。結構影響範囲大きいですねえ。


Using no_result_var in Journey's parser generator

actionpack/lib/action_dispatch/journey/parser.rbactionpack/lib/action_dispatch/journey/parser.yの修正です。

Journey parser generatorでは、値をreturnする際、一時変数に格納していたのですが、一時変数を使用するのは止めて、メソッドの戻り値をそのままreturnするよう修正しています。


Pull in the custom configuration concept from dhh/custom_configuration

dhhのcustom_configurationrailsにマージされました。

custom_configurationは、railsのconfigurationオブジェクトに任意の値を設定出来る、という機能です。

config.x.payment_processing.schedule = :daily
config.x.payment_processing.retries  = 3

上記の用に設定を行うと、下記のような使い方で値が取得出来ます。

Rails.configuration.x.payment_processing.schedule # => :daily
Rails.configuration.x.payment_processing.retries  # => 3

因みに"x"は決め打ち。ちょっと違和感があるのですが、他とバッティングしないようにする為に、しょうが無いんですかねえ。

あと、docに書いてあるサンプルが動かない…。ぬう。


Add suggestion as to how you can app the the assets load path

railties/lib/rails/generators/rails/app/templates/config/initializers/assets.rb.ttの修正です。

assets load pathへの値の設定方法について、サンプルを追加しています。

+# Add additional assets to the asset load path
+# Rails.application.config.assets.paths << Emoji.images_path

Explain why we use asset digests, not what a setter does

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

何故asset digestsを使用した方が良いのか、説明を追加しています。

静的ファイル全部asset digestsでちゃんと管理できてれば、キャッシュ ヘッダの設定遠い未来の値に設定出来るので、便利ですよねえ。


Merge pull request #16333 from joker1007/fix_decimal_cast_from_float_with_large_precision

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

高精度のFloatの値をDecimalにtype castする際に、エラーになっていたのを修正しています。

# before
type = ActiveRecord::Type::Decimal.new(precision: ::Float::DIG + 2)
type.type_cast_from_user(123.0)
# => ArgumentError: precision too large.

Float::DIGより大きな値の場合に問題があったようです。


Regenerate sid when sbdy tries to fixate the session

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

sessionの値を取得時に、sidの値を再生成するよう修正しています。

コケてたテストがあったので、その対応の為のようです。