aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/autosave_association_test.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/activerecord/test/cases/autosave_association_test.rb b/activerecord/test/cases/autosave_association_test.rb
index cf93d42942..ade1f4b44d 100644
--- a/activerecord/test/cases/autosave_association_test.rb
+++ b/activerecord/test/cases/autosave_association_test.rb
@@ -27,7 +27,6 @@ require "models/member_detail"
require "models/organization"
require "models/guitar"
require "models/tuning_peg"
-require "models/topic"
require "models/reply"
class TestAutosaveAssociationsInGeneral < ActiveRecord::TestCase
@@ -560,19 +559,18 @@ class TestDefaultAutosaveAssociationOnAHasManyAssociation < ActiveRecord::TestCa
end
def test_parent_should_not_get_saved_with_duplicate_children_records
- Topic.delete_all
-
- content = "Best content"
- reply1 = ValidateUniqueContentReply.new(content: content)
- reply2 = ValidateUniqueContentReply.new(content: content)
-
- topic = Topic.new(validate_unique_content_replies: [reply1, reply2])
-
- assert_not topic.save
- assert topic.errors.any?
-
- assert_equal 0, Topic.count
- assert_equal 0, ValidateUniqueContentReply.count
+ assert_no_difference "Reply.count" do
+ assert_no_difference "SillyUniqueReply.count" do
+ reply = Reply.new
+ reply.silly_unique_replies.build([
+ { content: "Best content" },
+ { content: "Best content" }
+ ])
+
+ assert_not reply.save
+ assert_not_empty reply.errors
+ end
+ end
end
def test_invalid_build