aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/belongs_to_associations_test.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/activerecord/test/cases/associations/belongs_to_associations_test.rb b/activerecord/test/cases/associations/belongs_to_associations_test.rb
index b8ec9117af..75f236aca0 100644
--- a/activerecord/test/cases/associations/belongs_to_associations_test.rb
+++ b/activerecord/test/cases/associations/belongs_to_associations_test.rb
@@ -377,4 +377,16 @@ class BelongsToAssociationsTest < ActiveRecord::TestCase
assert companies(:first_client).readonly_firm.readonly?
end
+ def test_save_fails_for_invalid_belongs_to
+ log = AuditLog.new
+ assert log.valid?
+
+ log.build_developer # Build invalid association
+ assert !log.developer.valid?
+ assert !log.valid?
+ assert_equal "is invalid", log.errors.on("developer")
+
+ assert !log.save
+ end
+
end