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:
parent
6bc02140a3
commit
d2542882b2
1 changed files with 14 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue