なるようになるブログ

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

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

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

rails 4.2 beta1がリリースされましたね。それもあってか、doc系の修正、Gemfile関係の修正が大量にありました。

そんな中、CHANGELOGにのったコミットは以下の通りです。

activerecord/CHANGELOG.md

actionmailer/CHANGELOG.md


minor copy editing [ci skip]

rails guideのCreating and Customizing Rails Generators & Templatesの修正です。

不要な行の削除。


Merge branch 'master' of github.com:rails/docrails

各docの修正です。

html -> HTML変換、ActionDispatch::FileHandlerActionDispatch::Staticクラスへのdocの追加等、docの改善。


Improve custom configuration

custom configurationの改善です。

configに"x"のnamespace無しでHashの値を設定出来るように改善しています。

config.resque = ActiveSupport::OrderedOptions.new
config.resque.inline_jobs = :always
config.resque.timeout     = 60

こんな感じで、最初のkeyにActiveSupport::OrderedOptionsを指定してあげる必要があるようです。


Add missing AS require

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

require 'active_support/core_ext/string/strip'を追加しています。


Add default .raise_in_transactional_callbacks option to template

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

テンプレートファイルに

<%- unless options.skip_active_record? -%>
# For not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
<%- end -%>

を追加しています。


Move TimeHelperTest to TimeTravelTest from as/test_test.rb

TimeHelperTestのテストをactivesupport/test/test_test.rbからactivesupport/test/time_travel_test.rbに移動しています。


Merge pull request #16299 from sikachu/ps-safer-ac-params

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

次のmajor updateでActionController::ParametersクラスはHash及びHashWithIndifferentAccessを継承するのを止める予定で元々使っていた幾つかの処理が行えなくなります。

その為、ActionController::Parametersto_hメソッドを追加し、同じような処理を行いたい場合、最初にto_hメソッドでHashに変換する必要があるとの事です。

params = ActionController::Parameters.new({
  name: 'Senjougahara Hitagi',
  oddity: 'Heavy stone crab'
})
params.to_h
# => {}

unsafe_params = params.dup.permit!
unsafe_params.to_h
# => {"name"=>"Senjougahara Hitagi", "oddity"=>"Heavy stone crab"}

safe_params = params.permit(:name)
safe_params.to_h
# => {"name"=>"Senjougahara Hitagi"}

Protect against error when parsing parameters with Bad Request

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

GETPOSTメソッドがrescueクラスに、Rack::Utils::InvalidParameterErrorを追加しています。

-    rescue TypeError => e
+    rescue TypeError, Rack::Utils::InvalidParameterError => e

元々InvalidParameterErrorTypeErrorを継承していたので問題無かったのですが、rackのこのコミットInvalidParameterErrorクラスの親クラスをArgumentErrorに変更している為、InvalidParameterErrorを追加したようです。

親クラスを変更するの、中々大きな対応な気がするのですが、ざっくりとやっちゃいますねえ。


Merge pull request #16349 from jmcnevin/master

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

schema_migrationsテーブルが無い場合に、ActiveRecord::Migrator.needs_migration?が正常な値を返すよう修正しています。


loofah require dependecy is not needed anymore

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

loofahを削除しています。


Fix the rails-dom-testing dependecy

各gemspecの修正です。

rails-dom-testingの追加及びバージョンの固定を行っています。


Bump ActiveJob's GlobalID dep to 0.2.3+ to fix Railties tests

activejob/activejob.gemspecの修正です。

globalidのバージョン指定を追加しています。


Use released rails-deprecated_sanitizer

各gemspecの修正です。

rails-deprecated_sanitizerのバージョン指定を追加しています。


Use released rails-html-sanitizer

各gemspecの修正です。

'rails-html-sanitizer'について、githubリポジトリを指定していいたのを削除しています。


Remove git dependecies

Gemfileの修正です。

rack及びglobalidを削除しています。


Add TODO note about the gems missing release

Gemfileの修正です。

以下の内容TODOを追加しています。

+# TODO: remove this before the 4.2.0.beta1 release
+gem 'turbolinks', github: 'rails/turbolinks', branch: 'master'

Move date and time requires to time_travel_test, also include

activesupport/test/time_travel_test.rbの修正です。

'active_support/core_ext/date'、'active_support/core_ext/numeric/time'のrequireを追加しています。


We always get the value so no need to check nil or Hash

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

ChainedConfigurationOptions#initializeメソッド引数の引数をが任意だったのを必須に変更しています。


[ci skip] Added documentation for belongs_to scope parameter

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

belongs_to scopeについてのサンプルを追加しています。

belongs_to :user, -> { where(id: 2) }
belongs_to :user, -> { joins(:friends) }
belongs_to :level, ->(level) { where("game_level > ?", level.current) }

Mention web-console in 4.2 release notes

guides/source/4_2_release_notes.mdrailties/CHANGELOG.mdの修正です。

web-consoleについての説明を追加しています。


Require rack/utils

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

require 'rack/utils'を追加しています。


Auth token mask from breach-mitigation-rails gem

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

auth tokenへのMask処理を追加しています。

SecureRandom.random_bytesでone time padを作成して、作成したone time padとCSRF tokenをXORした暗号化したtokenを作成し、 そのtokenとone time padを加算してtokenを作成する、という処理を行っています。

BREACH攻撃などでCSRF tokenがハイジャックされてしまった時の為の対応のようです。

因みに、元々breach-mitigation-railsというgemでやっていた内容を、rails本体にマージしたようです。


Revert "Improve custom configuration"

上で追加されたcustom configurationのコミットをrevertしています。リグレッションが発生した為との事です。追加はまた後で。


Require sprockets-rails 3.0.0.beta1

rails.gemspecの修正です。

s.add_dependency 'sprockets-rails', '~> 3.0.0.beta1'に修正しています。


Use web-console 2.0.0.beta2 on new apps

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

web-consoleについて、'2.0.0.beta1'固定だったのを'~> 2.0.0.beta2'に修正しています。


Synced Active Model changelogs [ci skip]

guides/source/4_2_release_notes.mdの修正です。

ActiveModelのchange logを反映しています。


Point to right sass-rails version

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

sass-railsのバージョン指定を5.0.0.beta1に修正しています。


Fix setting simple values to the new config.x

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

custom configurationの改善のrevertされた事に伴い、元々のcustom configurationのサンプルがちゃんと動作するよう修正しています。


Use the released turbolinks gem

Gemfileの修正です。

'turbolinks'について、githubリポジトリを指定していいたのを削除しています。


Synced Active Support release notes [ci skip]

guides/source/4_2_release_notes.mdの修正です。

ActiveSupportのchange logを反映しています。


Merge pull request #16570 from bradleybuda/breach-mitigation-mask-csrf-token


Synced AR release notes [ci-skip]

guides/source/4_2_release_notes.mdの修正です。

ActiveRecordのchange logを反映しています。


Fix blank link on config/application.rb app template [ci skip]

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

不要なスペースを削除しています。


Fix failing railties tests

railties/test/isolation/abstract_unit.rbの修正です。

configにactive recordの項目が追加された事に伴いコケてしまっていたテストを修正しています。


Major features in 4.2 release notes [ci skip]

guides/source/4_2_release_notes.mdの修正です。

Major featuresについての説明を追加しています。


List the 4.2 release notes in the index, mark it as WIP [ci skip]

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

4_2_release_notesを追加しています。


Clearly mark these as WIP, and invite people to contribute. [ci skip]

guides/source/4_1_release_notes.mdguides/source/upgrading_ruby_on_rails.mdの修正です。

WIPである旨注意を追加しています。PR募集中。


Some placeholders for the 4.2 upgrade guide [ci skip]

guides/source/upgrading_ruby_on_rails.mdの修正です。

幾つか項のタイトルを追加しています。タイトルをだけで、内容はまだ。


:bomb: oops, it should be 4.2 that's WIP [ci skip]

guides/source/4_2_release_notes.mdguides/source/4_1_release_notes.mdの修正です。

4_2_release_notesの方に追加すべき内容を4_1の方に追加してしまっていたのを修正しています。


:nail_care: The note doesn't look good on the blue background [ci skip]

guides/source/4_2_release_notes.mdの修正です。

フォーマットの修正。


Copy & paste fail [ci skip]

guides/source/4_2_release_notes.mdの修正です。

コピペが失敗した箇所を修正しています。


Create a group to active job gems

Gemfileの修正です。

group :jobを追加して、ActiveJobに関係するgemをまとめています。


Add set_delivery_method and restore_delivery_method to ActionMailer::TestCase.

actionmailer/lib/action_mailer/test_case.rbの修正です。

set_delivery_methodrestore_delivery_methodメソッドActionmailer::TestCaseに追加しています。

ActionMailer test suite外でも上記メソッドを使えるようにする為との事です。


Extra space

actionmailer/CHANGELOG.mdの修正です。

不要なスペースの削除。


Remove global helpers from the ActionMailer test suite.

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

先程Actionmailer::TestCaseに追加したset_delivery_methodrestore_delivery_methodメソッドを削除しています。


Only merge scopes with zero arity in has_many through

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

has_many throughを使用していて、かつ、その先のscopeでdynamic conditionsを使用していた場合にエラーになっていたのを対応しています。

has_many :comments, ->(developer) { where(body: "I'm #{developer.name}") }
has_many :ratings, through: :comments

上記のようなケースでエラーが発生してしまっていたようです。


Drop schema_migrations table only when exists

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

テストの最初にdrop_tableでテーブルを削除しているのですが、その際table_exists?('schema_migrations')でテーブルの存在チェックをし、テーブルがあるときのみ削除するようにしています。


[ci skip] "..enables interrorgating of [thing].." would be correct

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

グラマーの修正です。ofを追加しています。


Move as/test_test to as/test_case_test

activesupport/test/test_test.rbactivesupport/test/test_case_test.rbを移動しています。


Add documentation intro to example for Object#itself.

activesupport/lib/active_support/core_ext/object/itself.rbのdocの修正です。

Object$itselfのexampleを追加しています。


Updated the deprecation warnings to 5.0

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

Deprecation::initializeの引数deprecation_horizonのデフォルト値が'4.2'から'5.0'に変更しています。5.0ですねえ。


Ignore Postgresql "SELECT tablename FROM pg_tables" when counting queries

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

無視するQueryにSELECT tablename FROM pg_tablesを追加しています。


remove end-of-line spacing in development.rb, production.rb railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttrailties/lib/rails/generators/rails/app/templates/config/environments/production.rb.ttの修正です。

末尾の不要なスペースを削除しています。


Clear deliveries in order not to affect other tests

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

test_should_enqueue_and_run_correctly_in_activejobテストでensure処理でActionMailer::Base.deliveries.clearを行うよう修正しています。


Revert "Do not gsub non ASCII characters in header anchor.".

guideのmakrdownに関するこのコミットをrevertしています。


[ci skip] Format pass of Active Job Basics guide.

rails guideのActive Job Basicsの修正です。

markdownフォーマットの整理をしています。


Fixes the digits counter of AS's NumberToRoundedConverter

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

digit_countメソッドで引数のチェックを追加し、0だった場合1を設定するよう対応しています。

-          (Math.log10(absolute_number(number)) + 1).floor
+          number.zero? ? 1 : (Math.log10(absolute_number(number)) + 1).floor

Math.log10(0)が-Infinityを返してしまうので、zeroの場合1を設定して、 0.0を戻せるようにしたんですねえ。


Deprecated .deliver / .deliver! to .deliver_now / .deliver_now!

actionmailer/lib/action_mailer/message_delivery.rbの修正です。

deliverdeliver!メソッドがdeprecateになっています。Rails 5で削除予定

今後は、deliver_now!/deliver_later!deliver_now/deliver_laterを使用するようにとの事です。


Updated rdoc / guides / release notes related to ActiveJob / ActionMailer

上記deliver``deliver!メソッドの対応についてdocに追加しています。