Skip to content

Updated coerced test #1185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 10 additions & 12 deletions test/cases/coerced_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2197,25 +2197,23 @@ def test_insert_all_coerced
Task.cache { Task.insert({ starting: Time.now }) }
end

assert_called(ActiveRecord::Base.lease_connection, :clear_query_cache, times: 2) do
Task.cache { Task.insert_all!([{ starting: Time.now }]) }
end

assert_called(ActiveRecord::Base.lease_connection, :clear_query_cache, times: 2) do
Task.cache { Task.insert!({ starting: Time.now }) }
end

assert_called(ActiveRecord::Base.lease_connection, :clear_query_cache, times: 2) do
Task.cache { Task.insert_all!([{ starting: Time.now }]) }
end

assert_raises(ArgumentError, /does not support upsert/) do
Task.cache { Task.upsert({ starting: Time.now }) }
end

assert_raises(ArgumentError, /does not support upsert/) do
Task.cache { Task.upsert_all([{ starting: Time.now }]) }
end

Task.cache do
assert_called(ActiveRecord::Base.connection_pool.query_cache, :clear, times: 1) do
Task.insert_all!([ starting: Time.now ])
end

assert_called(ActiveRecord::Base.connection_pool.query_cache, :clear, times: 1) do
Task.insert!({ starting: Time.now })
end
end
end
end

Expand Down
Loading