なるようになるブログ

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

rails commit log流し読み(2015/12/16)

2015/12/16分のコミットです。

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

activerecord/CHANGELOG.md

activesupport/CHANGELOG.md


Remove warning of shadowing variable

actionpack/lib/action_controller/caching/fragments.rbの修正です。

ActionController::Caching::Fragments#fragment_cache_keyメソッドShadowing outer local variable warningが出ていたので、変数名を変更して対応しています。


Merge pull request #14212 from tylerhunt/fix-token-regex

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

authentication tokenにタブ(\t)が入っていても良いように、空白のチェックを"\s"で行うよう修正しています。

-      TOKEN_REGEX = /^(Token|Bearer) /
+      TOKEN_REGEX = /^(Token|Bearer)\s+/

Merge pull request #22562 from sblackstone/master

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

MySQL2 adapterの場合に、database.ymlflagsの値を指定出来るよう修正しています。

参考:mysql2/README.md at master · brianmario/mysql2


Do not default to any Serializer

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

rails apiの場合、デフォルトのGemfileでactive_model_serializersを使用するようになっていたのを、通常のrails app同様jbuilderを使用するよう修正しています。

コミットログにWe will wait until 5.1 to make a decisionと書かれているので、見送りになったんですねえ。


Update test generators to use ActionDispatch::IntegrationTest

railtiesの修正です。

先日、docだけ先に修正(Remove ActionController::TestCase from documentation)された対応の関連で、各generatorsが生成するテスト用のファイルでActionDispatch::IntegrationTestを使用するよう修正、及び既存のテストでActionDispatch::IntegrationTestを使用するよう修正しています。


Run railties generated app tests in test env

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

generatorsで生成されたファイルを実行するテストで、テストをdevelopment環境で実行してしまっていたのを、env環境で実行するようRAILS_ENVの指定を追加しています。


deletes code commented out in 72160d9f

actionpack/test/controller/helper_test.rbのdocの修正です。

helperのテストから、不要なコメントを削除しています。


deletes commented code introduced in 4673c47d

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

select_monthメソッドのテストから、不要なコメントを削除しています。


deletes commented code introduced in db045db (initial commit)

actionview/test/template/date_helper_test.rbactiverecord/test/cases/fixtures_test.rbの修正です。

#select_year#select_minute#select_second、の各メソッドのテスト、及びfixtureのテストから不要なコメントを削除しています。


deletes commented code introduced in f238d495

activesupport/bin/generate_tablesの修正です。

ActiveSupport::Multibyte::Unicode::DatabaseGenerator#parse_codepointsから不要なコメントを削除しています。


delete code commented out (and replaced) in e93d0a5

activesupport/lib/active_support/core_ext/time/calculations.rbの修正です。

Time#beginning_of_dayメソッドから不要なコメントを削除しています。


Introduce ApplicationRecord, an Active Record layer supertype

Active Recordの修正です。

generatorが生成するmodelクラスが全てApplicationRecordクラスの子クラスになるよう修正しています。

例。

# application_record.rb
class ApplicationRecord < ActiveRecord::Base
  self.abstract_class = true
end

# user.rb
class User < ApplicationRecord
end

今まではmodel classで直接ActiveRecord::Baseを継承していたのを、controllerやjob同様、application用の親クラスを挟むようになりました。

なお、app/models/application_record.rbが存在する場合のみmodelの親クラスがApplicationRecordとなるようになり、ファイルが存在しない場合は今まで通りActiveRecord::Baseが親クラスになります。


Deprecate passing string to define callback.

Active Supportの修正です。

callbackの定義にStringを使用するのがdeprecateになりました。

class Topic < ActiveRecord::Base
  before_destroy 'self.class.delete_all "parent_id = #{id}"'
end

こんなの出来たんですねえ。


Fix a couple of grammatical errors in security.md

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

Intranet and Admin Securityの項のグラマーの修正を行っています。