diff options
author | Emilio Tagua <miloops@gmail.com> | 2011-02-18 15:29:33 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2011-02-18 15:29:33 -0300 |
commit | 0b702ba3de42ed2ae8855843127f898102802b77 (patch) | |
tree | fc7d9b2fd78c3558dd978f3b67e5e58792551668 /activeresource | |
parent | 90a850aea4c2c04df22be0aaad1144468fcc8078 (diff) | |
parent | 1644663ba7f678d178deab2bf1629dc05626f85b (diff) | |
download | rails-0b702ba3de42ed2ae8855843127f898102802b77.tar.gz rails-0b702ba3de42ed2ae8855843127f898102802b77.tar.bz2 rails-0b702ba3de42ed2ae8855843127f898102802b77.zip |
Merge remote branch 'rails/master' into identity_map
Conflicts:
activerecord/lib/active_record/associations/association.rb
activerecord/lib/active_record/fixtures.rb
Diffstat (limited to 'activeresource')
-rw-r--r-- | activeresource/test/cases/validations_test.rb | 6 | ||||
-rw-r--r-- | activeresource/test/fixtures/project.rb | 19 |
2 files changed, 12 insertions, 13 deletions
diff --git a/activeresource/test/cases/validations_test.rb b/activeresource/test/cases/validations_test.rb index bd79fdd952..671d1ea8f0 100644 --- a/activeresource/test/cases/validations_test.rb +++ b/activeresource/test/cases/validations_test.rb @@ -48,6 +48,12 @@ class ValidationsTest < ActiveModel::TestCase assert p.save, "should have saved after fixing the validation, but had: #{p.errors.inspect}" end + def test_client_side_validation_maximum + project = Project.new(:description => '123456789012345') + assert ! project.valid? + assert_equal ['is too long (maximum is 10 characters)'], project.errors[:description] + end + protected # quickie helper to create a new project with all the required diff --git a/activeresource/test/fixtures/project.rb b/activeresource/test/fixtures/project.rb index e15fa6f620..53de666601 100644 --- a/activeresource/test/fixtures/project.rb +++ b/activeresource/test/fixtures/project.rb @@ -1,25 +1,18 @@ # used to test validations class Project < ActiveResource::Base self.site = "http://37s.sunrise.i:3000" + schema do + string :email + string :name + end - validates_presence_of :name + validates :name, :presence => true + validates :description, :presence => false, :length => {:maximum => 10} validate :description_greater_than_three_letters # to test the validate *callback* works def description_greater_than_three_letters errors.add :description, 'must be greater than three letters long' if description.length < 3 unless description.blank? end - - - # stop-gap accessor to default this attribute to nil - # Otherwise the validations fail saying that the method does not exist. - # In future, method_missing will be updated to not explode on a known - # attribute. - def name - attributes['name'] || nil - end - def description - attributes['description'] || nil - end end |