2014/07/17分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Fix decimal_test module and add new test for object responding to to_d
activerecord/test/cases/type/decimal_test.rb
の修正です。
to_d
メソッドのテストを追加しています。
Don't accept parameters as argument for redirect to [via @homakov]
actionpack/lib/action_controller/metal/redirecting.rb
の修正です。
redirect_to
の第一引数にActionController::Parameters
クラスの値を指定した場合に、ActionControllerError
をraiseするよう修正しています。
redirect_to params[:url]
という処理を行った時に、
1) XSS using url[status]=200&url[protocol]=javascript&url[f]=%0Aeval(name)
2) way to steal httponly session cookie url[status]=1
という問題が発生する可能性があり、その対応のようです。成る程。
activerecord/lib/active_record/enum.rb
の修正です。
非公開APIに:nodoc:を設定しています。
Revert "Rename to test_mysql_strict_mode_disabled_dont_override_global_sql_mode"
MySQLのConnectionAdapterのテストの修正をrevertしています。
対象のコミットはこちら。2年近く前のコミットですねえ。
MySQL 5.7.4-m14でテストがコケてしまうからrevertしたようです。
Added truncate_words method to activesupport strings
String#truncate_words
メソッドを追加しています。
文字数ではなく、単語数でtruncate処理を行うメソッドです。任意のセパレータで区切られている部分までを単語として扱って処理しています。セパレータはデフォルトではスペース。
"Hello Big World!".truncate_words(2) # => "Hello Big..." "Hello<br>Big<br>World!".truncate_words(2, separator: '<br>') # => "Hello<br>Big..." "Hello Big World!".truncate_words(2, omission: "[...]") # => "Hello Big[...]" "これは、テスト、メッセージ".truncate_words(2, separator: '、') # "これは、テスト..."
ちょっとおもしろいですね。使い道ありそうな。
actionpackのtestの修正です。使用していないfixturesを削除しています。
Added PartialIteration class used when rendering collections
actionviewの修正です。
collectionsをrenderする際に使用する為のPartialIteration
クラスを追加しています。
render partial: "customer_iteration", collection: [ Customer.new("david"), Customer.new("mary"), Customer.new('christine') ]
上記のようにrenderをした場合に、
# _customer_iteration.erb <%= customer_iteration_iteration.size %>-<%= customer_iteration_iteration.index %>: <%= customer_iteration.name %><%= '-first' if customer_iteration_iteration.first? %><%= '-last' if customer_iteration_iteration.last? %>
#{template_name}_iteration
変数でオブジェクトが呼び出せます。また、first?
、last?
メソッドも使用出来るようになっています。
No need to have a file to PartialIteration class
actionviewのPartialIteration
クラスの修正です。
上記コミットでPartialIteration
クラスをactionpack/lib/action_view/partial_iteration.rb
に新規追加していたのですが、他で使用してない為、クラスの定義をactionview/lib/action_view/renderer/partial_renderer.rb
に移動しています。
別ファイルのままで良さそうな気もしましたが、railsだとファイル数多くなりすぎるんですかねえ。
Build only one PartialIteration object for loop
まだPartialIteration
の修正です。
ループ処理でPartialIteration
のインスタンスを一度だけ作成するよう改善しています。
Document the PartialIteration object
まだまだPartialIteration
の修正です。
PartialIteration
クラスの各メソッドにdocを追加しています。
Add CHANGELOG entry for PartialIteration.
そしてPartialIteration
の対応について、CHANGELOGに追記しています。
actionview/lib/action_view/renderer/partial_renderer.rb
の修正です。
変数名のタイポを修正しています。
Merge pull request #15718 from chancancode/regression_from_15694
activerecord/lib/active_record/core.rb
の修正です。
allocate
メソッドを使用してインスタンスを生成した場合に、処理が大分遅くなってしまっていて、その改善の為の対応との事です。
always transcode the file to utf-8
actionpack/lib/action_dispatch/http/upload.rb
の修正です。
Http::UploadedFile
クラスのoriginal_filename
のエンコードにUTF-8を指定しています。
なので、ShiftJISのファイルをアップロードした場合でも、@original_filename
のエンコードは必ずUTF-8になっています。
Merge pull request #16183 from goddamnhippie/fix-psych-warning
activerecord/lib/active_record/connection_adapters/postgresql/oid/uuid.rb
の修正です。
PostgreSQLのUUID型に不正な値を指定した場合に、nilが設定されるよう対応しています。
バリデーションは、RFC4122に準じています。
extract inner options before delegating to the helper
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
call
メソッドにinner optionsを追加しています。helperにdelgateする前にoptionの値を取り除く為のようです。
Merge pull request #15917 from luke-gru/actionview_perf
actionview/lib/action_view/lookup_context.rb
の修正です。
DetailsKey::get
メソッドから不要なSet.new処理を削除しています。性能改善。
Use &= instead of select with include?
actionview/lib/action_view/lookup_context.rb
の修正です。
selectとinclude?の組み合わせの代わりに&=を使用するよう修正しています。
- syms = Mime::SET.symbols - details[:formats] = details[:formats].select { |v| - syms.include? v - } + details[:formats] &= Mime::SET.symbols
性能的には殆ど変わらないのですが、処理的に分り易いよね、という事で修正されています。
Fix typos in string_ext_test.rb [ci skip]
activesupport/test/core_ext/string_ext_test.rb
の修正です。
Remove unused 1:1 association :remote option
activerecord/lib/active_record/associations/builder/singular_association.rb
の修正です。
使用していない:remoteオプションを削除しています。 pre-1.0からずっとあったオプションらしいです。
we should be checking if the app is a class
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
app_name
メソッドでapp
のクラスチェック処理を修正しています。
本来はapp.is_a?(Class)
であるべき箇所が、app.class.is_a?(Class)
となってしまっていたようです。
app should always be a class (I suppose)
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
先ほどクラスチェック処理を修正していたのですが、app
は必ずクラスだろう、という事で、クラスチェック処理を削除しています。
Rails-ish apps should descend from Rails::Railtie
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
app
にroutesメソッドが定義されてるかどうかチェックしていたのを、クラスでチェックするよう修正しています
- return unless app.respond_to?(:routes) + return unless app.is_a?(Class) && app < Rails::Railtie
Module#< のチェックの仕方を初めて知りました。比較演算子で継承関係確認出来るんですねえ。
actionpack/lib/action_dispatch/routing/mapper.rb
の修正です。
app
のチェック処理を一度だけ行うよう修正しています。
we do not need to dup the options hash, it is private and a new object each call
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
不要なdup
処理を削除しています。
only extract :params from the options hash once
actionpack/lib/action_dispatch/http/url.rb
の修正です。
Hashのparams
キーの参照を一度だけ行うよう修正しています。
break out path building logic to methods
actionpack/lib/action_dispatch/http/url.rb
の修正です。
パラメータの組み立て処理をメソッドに切り出しています。
extract path building to a method
actionpack/lib/action_dispatch/http/url.rb
の修正です。
pathの組み立て処理をpath_for
メソッドからurl_for
メソッドに移動しています。
actionview/test/template/test_case_test.rb
の修正です。
テストで使用するappをRails::Engine
のサブクラスにしています。
Fix broken list formatting [ci skip]
actionview/lib/action_view/helpers/rendering_helper.rb
のdocの修正です。
RenderingHelper
のdocのlist formatが壊れてしまっていたのを、修正しています。
Remove need for macro instance var
activerecord/lib/active_record/reflection.rb
の修正です。
インスタンス変数のmacroを削除して、代わりにmacroメソッドを追加しています。
associationが設定されてない場合にNotImplementedError
をraise出来るように、メソッド変えたようです。
Remove "profile and benchmark" line from command line guide
rails guideのThe Rails Command Line
の修正です。
"profile and benchmark"行を削除しています。