diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-09-14 09:47:55 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-09-14 09:47:55 -0300 |
commit | 24260dc0c8338aef8e24407e00750fd72a0366ea (patch) | |
tree | 849b286decba65c1136947ef6f52235335df2383 /activemodel | |
parent | 0489f0c582d2ab70595296f058545b102466bebd (diff) | |
parent | 181cd109d9812d371e2d554a4846f0b2b25b1690 (diff) | |
download | rails-24260dc0c8338aef8e24407e00750fd72a0366ea.tar.gz rails-24260dc0c8338aef8e24407e00750fd72a0366ea.tar.bz2 rails-24260dc0c8338aef8e24407e00750fd72a0366ea.zip |
Merge commit 'rails/master'
Diffstat (limited to 'activemodel')
-rw-r--r-- | activemodel/lib/active_model/errors.rb | 3 | ||||
-rw-r--r-- | activemodel/lib/activemodel.rb | 1 | ||||
-rw-r--r-- | activemodel/test/cases/validations_test.rb | 16 |
3 files changed, 18 insertions, 2 deletions
diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 7a3001174f..590420de0b 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -1,7 +1,8 @@ require 'active_support/core_ext/string/inflections' +require 'active_support/ordered_hash' module ActiveModel - class Errors < Hash + class Errors < ActiveSupport::OrderedHash include DeprecatedErrorMethods def initialize(base) diff --git a/activemodel/lib/activemodel.rb b/activemodel/lib/activemodel.rb deleted file mode 100644 index da3133103b..0000000000 --- a/activemodel/lib/activemodel.rb +++ /dev/null @@ -1 +0,0 @@ -require 'active_model' diff --git a/activemodel/test/cases/validations_test.rb b/activemodel/test/cases/validations_test.rb index d44667e722..78565177d8 100644 --- a/activemodel/test/cases/validations_test.rb +++ b/activemodel/test/cases/validations_test.rb @@ -141,6 +141,22 @@ class ValidationsTest < ActiveModel::TestCase t = Topic.new("title" => "") assert !t.valid? assert_equal "can't be blank", t.errors["title"].first + Topic.validates_presence_of :title, :author_name + Topic.validate {|topic| topic.errors.add('author_email_address', 'will never be valid')} + Topic.validates_length_of :title, :content, :minimum => 2 + + t = Topic.new :title => '' + assert !t.valid? + + assert_equal :title, key = t.errors.keys.first + assert_equal "can't be blank", t.errors[key].first + assert_equal 'is too short (minimum is 2 characters)', t.errors[key].second + assert_equal :author_name, key = t.errors.keys.second + assert_equal "can't be blank", t.errors[key].first + assert_equal :author_email_address, key = t.errors.keys.third + assert_equal 'will never be valid', t.errors[key].first + assert_equal :content, key = t.errors.keys.fourth + assert_equal 'is too short (minimum is 2 characters)', t.errors[key].first end def test_invalid_should_be_the_opposite_of_valid |