Browse files

add test case

  • Loading branch information...
1 parent 8ea00ed commit aaf1af3cb83dad300c87e8abf2d1717cc528ff36 @gmarik gmarik committed Dec 31, 2013
Showing with 17 additions and 0 deletions.
  1. +17 −0 activerecord/test/cases/validations/presence_validation_test.rb
View
17 activerecord/test/cases/validations/presence_validation_test.rb
@@ -3,6 +3,8 @@
require 'models/man'
require 'models/face'
require 'models/interest'
+require 'models/speedometer'
+require 'models/dashboard'
class PresenceValidationTest < ActiveRecord::TestCase
class Boy < Man; end
@@ -48,4 +50,19 @@ def test_validates_presence_of_has_many_marked_for_destruction
i2.mark_for_destruction
assert b.invalid?
end
+
+
+ def test_validates_presence_doesnt_convert_to_array
+ Speedometer.validates_presence_of :dashboard
+
+ dash = Dashboard.new
+
+ # dashboard has to_a method
+ def dash.to_a; ['(/)', '(\)']; end
+
+ s = Speedometer.new
+ s.dashboard = dash
+
+ assert_nothing_raised { s.valid? }
+ end
end

0 comments on commit aaf1af3

Please sign in to comment.