Checking foreign key constraints on message recipients and senders
authorAndy Allan <gravitystorm@gmail.com>
Wed, 15 Oct 2008 15:23:56 +0000 (15:23 +0000)
committerAndy Allan <gravitystorm@gmail.com>
Wed, 15 Oct 2008 15:23:56 +0000 (15:23 +0000)
test/unit/message_test.rb

index 362bcc4307d965308c7247fd56ea9a46fc2d7a93..e95c698c9c787a0a8565caedab5bfb457e9d4358 100644 (file)
@@ -32,6 +32,11 @@ class MessageTest < Test::Unit::TestCase
     message.sender = nil
     message.recipient = nil
     assert !message.valid?
+
+    assert_raise(ActiveRecord::RecordNotFound) { User.find(0) }
+    message.from_user_id = 0
+    message.to_user_id = 0
+    assert_raise(ActiveRecord::RecordInvalid) {message.save!}
   end
 
   def test_utf8_roundtrip