2014/05/03分のコミットです。
Add singular and plural form for some validation messages
length validator'sのデフォルトのメッセージに単数形のパターンを追加しています。
以下コミットログの抜粋。
- too_long: "is too long (maximum is %{count} characters)" - too_short: "is too short (minimum is %{count} characters)" - wrong_length: "is the wrong length (should be %{count} characters)" + too_long: + one: "is too long (maximum is 1 character)" + other: "is too long (maximum is %{count} characters)" + too_short: + one: "is too short (minimum is 1 character)" + other: "is too short (minimum is %{count} characters)" + wrong_length: + one: "is the wrong length (should be 1 character)" + other: "is the wrong length (should be %{count} characters)"
元々は複数形のパターンだけだったのに、単数形が追加されています。
i18n対応で少し追随が必要そう。
eliminate repetition in guide links for past releases [ci skip]
rails guideの修正です。
_welcome.html.erb
から過去のバージョンのguideページへのリンクを削除して、最新のバージョンへのリンクを載せるようにしています。
passing a nil should always raise an ArgumentError
ActionDispatch::Routing::PolymorphicRoutes#polymorphic_url
メソッドの修正です。
polymorphic_url
の第一引数にnilが含まれていた場合に、ArgumentErrorがraiseするよう修正しています。
元々は、compact
メソッドを使ってnilを除去していたのですが、compact
メソッドの呼び出しを削除しています。
push up bind params on "simple" subquery calculations
make db:structure:load
listed with rake -T
activerecord/lib/active_record/railties/databases.rake
の修正です。
db:structure:load
タスクをrake -T
コマンドに表示されるよう修正しています。
db:structure:load
はstructure.sqlからDBを作り直す為のコマンドのようです。
structure.sql使った事無かったのですが、生のSQLになるので、schema.rbで管理しきれない特殊なケースの時は良いのかもしれないですね。
passing a nil in the polymorphic array is not supported. remove nils before you call the method
ActionDispatch::Routing::PolymorphicRoutes#polymorphic_url
メソッドの修正です。
polymorphic_url
の第一引数にnilが含まれていた場合に、ArgumentErrorがraiseするよう修正しています。
passing a nil should always raise an ArgumentErrorのコミットは、実際のArgumentErrorは呼び出し先のメソッドで起きていたのですが、こちらのコミットではpolymorphic_url
内でnilチェックを行い、nilが含まれていたらpolymorphic_url
でArgumentErrorを発生するように対応しています。
Move dup destroyed test to specific file that tests dup logic
test_dup_not_destroyed
のテストメソッドをactiverecord/test/cases/persistence_test.rb
からactiverecord/test/cases/dup_test.rb
に移動しています。
dup_test.rb
にある方がテスト内容を考えると適切だからですかね。
Add branch to arel on Gemfile to allow local bundle config [ci skip]
Gemfileのarel
にbranch: 'master'
を追記しています。
Add missing require to fix test :bomb:
activerecord/test/cases/dup_test.rb
の修正です。
require 'models/reply'
を追加しています。 requireが足りてなくてテストがコケてたようです。
Use #include? instead of #any?, make it simpler
先にあったpolymorphic_url
のnilのチェックの処理を
- if record_or_hash_or_array.any?(&:nil?) + if record_or_hash_or_array.include? nil
のように修正しています。この場合だと、確かにinclude?
使った方がわかりやすい気がします。
Test typecasting on instance rather than class itself
activerecord/test/cases/adapters/sqlite3/quoting_test.rb
のtest_quoted_id
メソッドの修正です。
new
メソッドの呼び出しを追加して、インスタンスを生成するようにしています。
classよりも、インスタンスの方が良い、というより、そもそもインスタンスでテスト行わないとダメそうな。
Merge pull request #14924 from eric-chahin/issue_13854
activerecord/lib/active_record/autosave_association.rb
の修正です。
autosave associationsを指定していて、validationを行う際、contextの判定がおかしかったバグを修正しています。
テストコード抜粋。
pirate = FamousPirate.new pirate.famous_ships << ship = FamousShip.new assert_equal true, pirate.valid? assert_equal false, pirate.valid?(:conference) assert_equal "can't be blank", ship.errors[:name].first
FamousShip
はon: :conference
でvalidationを設定しているので上記動作が期待されるのですが、元々は4行目のpirate.valid?(:conference)
もtrueになってしまっていたようです。