1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Extract insert test case from #35686

This commit is contained in:
Kasper Timm Hansen 2019-03-31 20:41:18 +02:00
parent 6bc02140a3
commit d2542882b2
No known key found for this signature in database
GPG key ID: 191153215EDA53D8

View file

@ -11,6 +11,20 @@ class InsertAllTest < ActiveRecord::TestCase
fixtures :books fixtures :books
def test_insert def test_insert
skip unless supports_insert_on_duplicate_skip?
id = 1_000_000
assert_difference "Book.count", +1 do
Book.insert(id: id, name: "Rework", author_id: 1)
end
Book.upsert(id: id, name: "Remote", author_id: 1)
assert_equal "Remote", Book.find(id).name
end
def test_insert!
assert_difference "Book.count", +1 do assert_difference "Book.count", +1 do
Book.insert! name: "Rework", author_id: 1 Book.insert! name: "Rework", author_id: 1
end end