@@ -1341,6 +1341,14 @@ def test_registering_new_handlers_for_association_coerced
1341
1341
assert_match %r{#{ Regexp . escape ( topic_title ) } ~ N'rails'}i , Reply . joins ( :topic ) . where ( topics : { title : /rails/ } ) . to_sql
1342
1342
end
1343
1343
1344
+ # Same as original test except string has `N` prefix to indicate unicode string.
1345
+ coerce_tests! :test_registering_new_handlers_for_joins
1346
+ def test_registering_new_handlers_for_joins_coerced
1347
+ Reply . belongs_to :regexp_topic , -> { where ( title : /rails/ ) } , class_name : "Topic" , foreign_key : "parent_id"
1348
+
1349
+ assert_match %r{#{ Regexp . escape ( quote_table_name ( "regexp_topic.title" ) ) } ~ N'rails'}i , Reply . joins ( :regexp_topic ) . references ( Arel . sql ( "regexp_topic" ) ) . to_sql
1350
+ end
1351
+
1344
1352
private
1345
1353
1346
1354
def topic_title
@@ -2177,17 +2185,6 @@ class EnumTest < ActiveRecord::TestCase
2177
2185
Book . lease_connection . add_index ( :books , [ :author_id , :name ] , unique : true )
2178
2186
end
2179
2187
2180
- # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
2181
- coerce_tests! %r{declare multiple enums at a time}
2182
- test "declare multiple enums at a time coerced" do
2183
- Book . lease_connection . remove_index ( :books , column : [ :author_id , :name ] )
2184
-
2185
- send ( :'original_declare multiple enums at a time' )
2186
- ensure
2187
- Book . where ( author_id : nil , name : nil ) . delete_all
2188
- Book . lease_connection . add_index ( :books , [ :author_id , :name ] , unique : true )
2189
- end
2190
-
2191
2188
# Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
2192
2189
coerce_tests! %r{serializable\? with large number label}
2193
2190
test "serializable? with large number label coerced" do
@@ -2669,6 +2666,28 @@ def test_url_invalid_adapter_coerced
2669
2666
end
2670
2667
end
2671
2668
2669
+ module ActiveRecord
2670
+ module ConnectionAdapters
2671
+ class RegistrationIsolatedTest < ActiveRecord ::TestCase
2672
+ # SQL Server was not included in the list of available adapters in the error message.
2673
+ coerce_tests! %r{resolve raises if the adapter is using the pre 7.2 adapter registration API}
2674
+ def resolve_raises_if_the_adapter_is_using_the_pre_7_2_adapter_registration_API
2675
+ exception = assert_raises ( ActiveRecord ::AdapterNotFound ) do
2676
+ ActiveRecord ::ConnectionAdapters . resolve ( "fake_legacy" )
2677
+ end
2678
+
2679
+ assert_equal (
2680
+ "Database configuration specifies nonexistent 'ridiculous' adapter. Available adapters are: abstract, fake, mysql2, postgresql, sqlite3, sqlserver, trilogy. Ensure that the adapter is spelled correctly in config/database.yml and that you've added the necessary adapter gem to your Gemfile if it's not in the list of available adapters." ,
2681
+ exception . message
2682
+ )
2683
+ ensure
2684
+ ActiveRecord ::ConnectionAdapters . instance_variable_get ( :@adapters ) . delete ( "fake_legacy" )
2685
+ end
2686
+ end
2687
+ end
2688
+ end
2689
+
2690
+
2672
2691
module ActiveRecord
2673
2692
class TableMetadataTest < ActiveSupport ::TestCase
2674
2693
# Adapter returns an object that is subclass of what is expected in the original test.
0 commit comments