Skip to content

Commit a19b998

Browse files
aidanharanandyundso
andcommitted
Fixed tests
Co-Authored-By: Andy Pfister <[email protected]>
1 parent 71eb08b commit a19b998

File tree

1 file changed

+16
-44
lines changed

1 file changed

+16
-44
lines changed

test/cases/coerced_tests.rb

+16-44
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,22 @@ def test_payload_row_count_on_raw_sql_coerced
376376
end
377377

378378
class CalculationsTest < ActiveRecord::TestCase
379+
# SELECT columns must be in the GROUP clause.
380+
coerce_tests! :test_should_count_with_group_by_qualified_name_on_loaded
381+
def test_should_count_with_group_by_qualified_name_on_loaded_coerced
382+
accounts = Account.group("accounts.id").select("accounts.id")
383+
384+
expected = {1 => 1, 2 => 1, 3 => 1, 4 => 1, 5 => 1, 6 => 1}
385+
386+
assert_not_predicate accounts, :loaded?
387+
assert_equal expected, accounts.count
388+
389+
accounts.load
390+
391+
assert_predicate accounts, :loaded?
392+
assert_equal expected, accounts.count(:id)
393+
end
394+
379395
# Fix randomly failing test. The loading of the model's schema was affecting the test.
380396
coerce_tests! :test_offset_is_kept
381397
def test_offset_is_kept_coerced
@@ -2200,35 +2216,6 @@ class EnumTest < ActiveRecord::TestCase
22002216
end
22012217
end
22022218

2203-
require "models/task"
2204-
class QueryCacheExpiryTest < ActiveRecord::TestCase
2205-
# SQL Server does not support skipping or upserting duplicates.
2206-
coerce_tests! :test_insert_all
2207-
def test_insert_all_coerced
2208-
assert_raises(ArgumentError, /does not support skipping duplicates/) do
2209-
Task.cache { Task.insert({ starting: Time.now }) }
2210-
end
2211-
2212-
assert_raises(ArgumentError, /does not support upsert/) do
2213-
Task.cache { Task.upsert({ starting: Time.now }) }
2214-
end
2215-
2216-
assert_raises(ArgumentError, /does not support upsert/) do
2217-
Task.cache { Task.upsert_all([{ starting: Time.now }]) }
2218-
end
2219-
2220-
Task.cache do
2221-
assert_called(ActiveRecord::Base.connection_pool.query_cache, :clear, times: 1) do
2222-
Task.insert_all!([ starting: Time.now ])
2223-
end
2224-
2225-
assert_called(ActiveRecord::Base.connection_pool.query_cache, :clear, times: 1) do
2226-
Task.insert!({ starting: Time.now })
2227-
end
2228-
end
2229-
end
2230-
end
2231-
22322219
require "models/citation"
22332220
class EagerLoadingTooManyIdsTest < ActiveRecord::TestCase
22342221
fixtures :citations
@@ -2542,21 +2529,6 @@ def invalid_add_column_option_exception_message(key)
25422529
end
25432530
end
25442531

2545-
# SQL Server does not support upsert. Removed dependency on `insert_all` that uses upsert.
2546-
class ActiveRecord::Encryption::ConcurrencyTest < ActiveRecord::EncryptionTestCase
2547-
undef_method :thread_encrypting_and_decrypting
2548-
def thread_encrypting_and_decrypting(thread_label)
2549-
posts = 100.times.collect { |index| EncryptedPost.create! title: "Article #{index} (#{thread_label})", body: "Body #{index} (#{thread_label})" }
2550-
2551-
Thread.new do
2552-
posts.each.with_index do |article, index|
2553-
assert_encrypted_attribute article, :title, "Article #{index} (#{thread_label})"
2554-
article.decrypt
2555-
assert_not_encrypted_attribute article, :title, "Article #{index} (#{thread_label})"
2556-
end
2557-
end
2558-
end
2559-
end
25602532

25612533
# Need to use `install_unregistered_type_fallback` instead of `install_unregistered_type_error` so that message-pack
25622534
# can read and write `ActiveRecord::ConnectionAdapters::SQLServer::Type::Data` objects.

0 commit comments

Comments
 (0)