From 1bedee56314ff1de2d186ca56adbe4059f4b0af3 Mon Sep 17 00:00:00 2001 From: Ken Mazaika Date: Sun, 13 Feb 2011 19:32:27 -0500 Subject: ActiveResource validation tests did not test ActiveModel validations. Adjust the test to be done the Rails3 way. Signed-off-by: Santiago Pastorino --- activeresource/test/fixtures/project.rb | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'activeresource/test/fixtures/project.rb') 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 -- cgit v1.2.3