module NestedAttributesLimitTests
Public Instance Methods
teardown()
click to toggle source
# File activerecord/test/cases/nested_attributes_test.rb, line 898 def teardown Pirate.accepts_nested_attributes_for :parrots, allow_destroy: true, reject_if: proc(&:empty?) end
test_limit_with_exceeding_records()
click to toggle source
# File activerecord/test/cases/nested_attributes_test.rb, line 912 def test_limit_with_exceeding_records assert_raises(ActiveRecord::NestedAttributes::TooManyRecords) do @pirate.attributes = { parrots_attributes: { "foo" => { name: "Lovely Day" }, "bar" => { name: "Blown Away" }, "car" => { name: "The Happening" } } } end end
test_limit_with_less_records()
click to toggle source
# File activerecord/test/cases/nested_attributes_test.rb, line 902 def test_limit_with_less_records @pirate.attributes = { parrots_attributes: { "foo" => { name: "Big Big Love" } } } assert_difference("Parrot.count") { @pirate.save! } end
test_limit_with_number_exact_records()
click to toggle source
# File activerecord/test/cases/nested_attributes_test.rb, line 907 def test_limit_with_number_exact_records @pirate.attributes = { parrots_attributes: { "foo" => { name: "Lovely Day" }, "bar" => { name: "Blown Away" } } } assert_difference("Parrot.count", 2) { @pirate.save! } end