2015/01/28分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
Fix typo on guide name [ci skip]
guides/source/documents.yaml
の修正です。
"Active Model basics" -> "Active Model Basics"にタイポを修正しています。
Unify access to bind values on Relation
ActiveRecordの修正です。
QueryMethods#bind_values
メソッドがarel.bind_values
の値も加えて返すよう修正しています。
- from_clause.binds + where_clause.binds + having_clause.binds + from_clause.binds + arel.bind_values + where_clause.binds + having_clause.binds
arel.bind_values + relation.bind_values
みたいな事をやっているコードが多々あったのが、relation.bind_values
だけで済むようになり、大分スッキリしています。
Move where grouping into WhereClause
activerecord/lib/active_record/relation/query_methods.rb
、
activerecord/lib/active_record/relation/where_clause.rb
の修正です。
QueryMethods
moduleにあったwhere
のグルーピング処理をWhereClause
クラスに移動しています。
Use the WhereClause
ast building logic for having
activerecord/lib/active_record/relation/query_methods.rb
の修正です。
build_arel
メソッドでhaving
のロジックを構築するさい、WhereClause#ast
メソッドを使用するよう修正しています。
先日having
についてもWhereClause
クラスを使うよう修正したので、その対応の続きですかねえ。
WhereClause#predicates
does not need to be public
activerecord/lib/active_record/relation/where_clause.rb
の修正です。
WhereClause#predicates
をpublicからprotectedに修正しています。
今の所テストでしか必要としてないので、protectedに修正したとの事です。
Minor refactorings on Relation#build_joins
activerecord/lib/active_record/relation/query_methods.rb
の修正です。
Relation#build_joins
のリファクタリングです。メソッド名を適切な名前に変更、不要なnil判定処理の削除等を行っています。
Don't rely on the internal representation of join values
activerecord/lib/active_record/associations/preloader.rb
、
activerecord/lib/active_record/associations/preloader/association.rb
の修正です。
preload_values
Hashから直接値を取得していたのを、メソッド経由で取得するよう修正しています。
Use an Attribute
object to represent a bind value
ActiveRecordの修正です。
bind valueの格納先をHashからAttribute
クラスを使用するよう修正しています。
All subclasses of Attribute
should be private constants
activerecord/lib/active_record/attribute.rb
の修正です。
Attribute::WithCastValue
クラスをprivateに修正しています。
fix typo still cause -> still causes
activerecord/lib/active_record/attribute_methods/time_zone_conversion.rb
のdocの修正です。
still cause
-> still causes
にタイポを修正しています。
ActiveRecordの修正です。
Relation#bind_values
を削除し、代わりにRelation#bound_attributes
を使用するよう修正しています。
bound_attributes
では、from_clause、arel、 where_clause、having_clauseそれぞれのbindしたvalueをまとめて返すようにしています。コミットログがRelation#bind_params
を削除した、になってるのは、多分ただのタイポだと思うのですが…。
improve performance of integration tests.
actionpack/lib/action_dispatch/routing/route_set.rb
の修正です。
url_helpers
メソッドでdelegate
メソッドでメソッドの移譲を行っていたのを、普通にメソッド定義するよう修正しています。
- delegate :url_for, :optimize_routes_generation?, to: '@_routes' + def url_for(options) + @_routes.url_for(options) + end + + def optimize_routes_generation? + @_routes.optimize_routes_generation? + end
delegate
メソッドがボトルネックになっていた事。PRにあったstackprofの実行結果は以下の通り。
require 'test_helper' class DocumentsIntegrationTest < ActionDispatch::IntegrationTest test "index" do get '/documents' assert_equal 200, response.status end end Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') StackProf.run(mode: :wall, out: 'stackprof.dump') do 3000.times do Minitest.run_one_method(DocumentsIntegrationTest, 'test_index') end end
================================== Mode: wall(1000) Samples: 23694 (7.26% miss rate) GC: 1584 (6.69%) ================================== TOTAL (pct) SAMPLES (pct) FRAME 7058 (29.8%) 6178 (26.1%) block in Module#delegate 680 (2.9%) 680 (2.9%) ActiveSupport::PerThreadRegistry#instance 405 (1.7%) 405 (1.7%) ThreadSafe::NonConcurrentCacheBackend#[] 383 (1.6%) 383 (1.6%) Set#include? 317 (1.3%) 317 (1.3%) ActiveRecord::Base.logger 281 (1.2%) 281 (1.2%) Rack::Utils::HeaderHash#[]= 269 (1.1%) 269 (1.1%) ActiveSupport::Notifications::Fanout::Subscribers::Evented#subscribed_to? 262 (1.1%) 262 (1.1%) block (4 levels) in Class#class_attribute 384 (1.6%) 246 (1.0%) block (2 levels) in Class#class_attribute
Merge pull request #18666 from cheunghy/auth_check_nil
actionpack/lib/action_controller/metal/http_authentication.rb
の修正です。
Basic認証で、request.authorization
がnilの場合にundefined method になってしまっていたので、
auth_scheme
、auth_param
メソッドで引数のStringへの変換処理を追加しています。
Return value of yielded block in File.atomic_write
activesupport/lib/active_support/core_ext/file/atomic.rb
の修正です。
File.atomic_write
メソッドの引数にブロックを渡した場合に、ブロックをyieldした値をメソッドの戻り値として返すよう修正しています。
block_return_value = File.atomic_write(file_name, Dir.pwd) do |file| "Hello world!" end block_return_value # => "Hello world!"
introduce ActiveSupport::Testing::FileFixtures
.
activesupport/lib/active_support/test_case.rb
、
activesupport/lib/active_support/testing/file_fixtures.rb
の修正です。
ActiveSupport::TestCase
クラスに、テスト用のシンプルなファイルにアクセスする為のfile_fixture
メソッドを追加しています。
file_fixture("example.txt").read # get the file's content file_fixture("example.mp3").size # get the file size
デフォルトはtest/fixtures/files
に格納されているファイルを読み込みます。パスはfile_fixture_path
で変更可能。
Deprecate *_via_redirect integration test methods
actionpack/lib/action_dispatch/testing/integration.rb
の修正です。
integrationテスト用ヘルパーメソッドの*_via_redirect
がdeprecateになりました。代わりにfollow_redirect!
メソッドの方を使うように、との事です。