Permalink
Browse files

Got ActiveModel validations to pass... finally... FML

  • Loading branch information...
1 parent 2c7e7fe commit c8be2db6a6df42a3db905a421e2662cb9f47baf4 @treeder treeder committed Feb 8, 2011
Showing with 11 additions and 3 deletions.
  1. +9 −3 lib/simple_record.rb
  2. +2 −0 test/test_validations.rb
View
12 lib/simple_record.rb
@@ -503,30 +503,36 @@ def save(options={})
def create_or_update #:nodoc:
puts 'create_or_update'
+ ret = true
_run_save_callbacks do
result = new_record? ? create : update
puts 'save_callbacks result=' + result.inspect
- return result
+ ret = result
end
+ ret
end
def create #:nodoc:
puts '3 create'
+ ret = true
_run_create_callbacks do
x = old_save
puts 'create old_save result=' + x.to_s
- return x
+ ret = x
end
+ ret
end
#
def update(*) #:nodoc:
puts '3 update'
+ ret = true
_run_update_callbacks do
x = old_save
puts 'update old_save result=' + x.to_s
- return x
+ ret = x
end
+ ret
end
View
2 test/test_validations.rb
@@ -15,9 +15,11 @@ class TestSimpleRecord < TestBase
def test_validations
mm = MyModel.new()
+ puts 'invalid? ' + mm.invalid?.to_s
assert mm.invalid?, "mm is valid. invalid? returned #{mm.invalid?}"
assert mm.errors.size == 1
assert !mm.attr_before_create
+ assert !mm.valid?
assert mm.save == false, mm.errors.inspect
assert mm.attr_before_create
assert !mm.attr_after_save

0 comments on commit c8be2db

Please sign in to comment.