2014/05/08分のコミットです。
has_and_belongs_to_many
を使用している際にsize
が誤っていたバグの修正が行われています。
test, persist inherited class with different table name. Refs #14971.
activerecord/test/cases/persistence_test.rb
の修正です。
テーブル名と違うクラスでの永続化の振る舞いの確認のテストです。
inimalistic_aircrafts = Class.new(Minimalistic) do self.table_name = "aircraft" end assert_difference "Aircraft.count", 1 do aircraft = minimalistic_aircrafts.create(name: "Wright Flyer") aircraft.name = "Wright Glider" aircraft.save end assert_equal "Wright Glider", Aircraft.last.name
Aircraft.count
が1にならないのはちょっと違和感が。
add tests for symbols passed to polymorphic_url
actionview/test/activerecord/polymorphic_routes_test.rb
の修正です。
polymorphic_url
メソッドのテストを追加しています。
HTTP::Headers#key? correctly converts
HTTP::Headers#key?
メソッドの修正です。
keyのチェック処理が誤っていたのを修正しています。
env = { "CONTENT_TYPE" => "text/plain" } headers = ActionDispatch::Http::Headers.new(env) headers["Content-Type"] # => "text/plain" headers.key?("Content-Type") # => false
上記の実行結果がtrueになるように修正されています。
test for inconsistency between String and Symbol url_for handling
actionview/test/activerecord/polymorphic_routes_test.rb
の修正です。url_for
メソッドのテストケースを追加しています。
assert_equal "http://example.com/projects", polymorphic_url("projects") assert_equal "projects", url_for("projects") assert_equal "http://example.com/projects", polymorphic_url(:projects) assert_equal "http://example.com/projects", url_for(:projects)
url_for
メソッドはString
/Symbol
で挙動が違うんですね。
Merge pull request #13166 from bogdan/transaction-magic
ActiveRecord::Transactions
の修正です。
ちょっとややこしいのでテストコードから抜粋。
assert !model.approved? Topic.transaction do model.approved = true model.save! raise ActiveRecord::Rollback end model.save! assert @first.reload.approved
最後のmodel.save!
でデータが更新されないというバグがあり、正しく値が更新されるよう修正されています。
一度Rollbackが走っている場合状態なので、ちょっと特殊なケースな気がします。なお、Rails 3.2では元々上記動作でしたので、処理を戻した形ですになります。
Keep track of dirty attrs after after rollback.
上記コミットの追加修正です。
テストメソッドがxxx1、xxx2になっていたのの修正、不要な変数の削除など。
Merge pull request #12746 from coreyward/master
Hash#deep_merge
メソッドのバグの修正及びdocの修正です。
Hashにfalseの値があった時の挙動を修正しています。
# before hash_1 = { e: false } hash_2 = { e: 'e' } hash_1.deep_merge(hash_2) { |k, o, n| [k, o, n] } # {:e=>"e"} # after hash_1 = { e: false } hash_2 = { e: 'e' } hash_1.deep_merge(hash_2) { |k, o, n| [k, o, n] } # {:e=>[:e, false, "e"]}
Return a non zero code when db has never been setup on status
activerecord/lib/active_record/railties/databases.rake
の修正です。
db:migrate:status
で、dbのセットアップがされていない場合、abort
メソッドで処理を終了するようにしています。
元々はputs
でメッセージ表示するだけだったので、終了ステータスみても0で、正常/異常が分からなかったんですねえ。
Add CHANGELOG entry for #14989
上記修正について、CHANGELOに追加しています。
Use Rails::Paths::Path#existent in database_configuration
Rails::Application::Rails::Engine::Configuration::Configuration#database_configuration
メソッドの修正です。
"config/database"
に存在しないファイルのパスが設定されていた場合に、エラーになってしまっていたのですが、existent
メソッドを挟むようにして、ファイルの存在チェックをいれるようにしてます。
application.rbにconfig.paths.add 'config/database, with: xxx'
を設定する事でdatabases.yml
以外のファイルを使うことが出来るんですね。知らなかった。
Dup the changed_attributes otherwise we could lose them
ActiveRecord::Transactions
の修正です。
このコミット以降、テストが壊れてしまったらしく、その対処との事。
- @_start_transaction_state[:changed_attributes] ||= changed_attributes + @_start_transaction_state[:changed_attributes] ||= changed_attributes.dup
元の値を壊さないよう、dup
した値を渡すように修正されています。
Branch name should match in text and code example.
rails guideのContributing to Ruby on Rails
の修正です。
Older Versions of Ruby on Rails
の項のブランチを3.0 -> 4.0に修正しています。
Fixed HABTM's CollectionAssociation size
ActiveRecord::Associations::HasManyAssociation::HasManyThroughAssociation#size
メソッドの修正です。
has_and_belongs_to_many
を使用している際に、返す値を誤っていたのを修正しています。
pg guide, inet code example. [ci skip]
rails guideのActive Record and PostgreSQL
のページの修正です。 inetについてのexampleを追加しています。
test, reset changed state in PG's uuid tests.
activerecord/test/cases/adapters/postgresql/uuid_test.rb
の修正です。
カラムが無くてエラーになってしまうケースがあったらしく、UUIDType.reset_column_information
を追加しています。
test, regression test for unparsable PostgreSQL defaults.
activerecord/test/cases/adapters/postgresql/postgresql_adapter_test.rb
へのテストコードの追加です。
defaultにパース出来ない値が設定された場合のテストケースを追加しています。
現状は動いているのですが、こちらのPRで処理の修正を行っているらしく、そちらがマージされたら壊れる予定。