@@ -879,15 +879,15 @@ def test_relations_dont_load_all_records_in_inspect_coerced
879
879
# so we are skipping all together.
880
880
coerce_tests! :test_empty_complex_chained_relations
881
881
882
- # Can't apply offset withour ORDER
882
+ # Can't apply offset without ORDER
883
883
coerce_tests! %r{using a custom table affects the wheres}
884
884
test 'using a custom table affects the wheres coerced' do
885
885
post = posts ( :welcome )
886
886
887
887
assert_equal post , custom_post_relation . where! ( title : post . title ) . order ( :id ) . take
888
888
end
889
889
890
- # Can't apply offset withour ORDER
890
+ # Can't apply offset without ORDER
891
891
coerce_tests! %r{using a custom table with joins affects the joins}
892
892
test 'using a custom table with joins affects the joins coerced' do
893
893
post = posts ( :welcome )
@@ -1151,10 +1151,21 @@ class CollectionCacheKeyTest < ActiveRecord::TestCase
1151
1151
1152
1152
1153
1153
1154
+ require "models/book"
1154
1155
module ActiveRecord
1155
1156
class StatementCacheTest < ActiveRecord ::TestCase
1156
1157
# Getting random failures.
1157
1158
coerce_tests! :test_find_does_not_use_statement_cache_if_table_name_is_changed
1159
+
1160
+ # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1161
+ coerce_tests! :test_statement_cache_values_differ
1162
+ def test_statement_cache_values_differ_coerced
1163
+ Book . connection . remove_index ( :books , column : [ :author_id , :name ] )
1164
+
1165
+ original_test_statement_cache_values_differ
1166
+ ensure
1167
+ Book . connection . add_index ( :books , [ :author_id , :name ] , unique : true )
1168
+ end
1158
1169
end
1159
1170
end
1160
1171
@@ -1264,3 +1275,47 @@ class DatabaseTasksTruncateAllTest < ActiveRecord::TestCase
1264
1275
coerce_tests! :test_truncate_tables
1265
1276
end
1266
1277
end
1278
+
1279
+
1280
+ require "models/book"
1281
+ class EnumTest < ActiveRecord ::TestCase
1282
+ # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1283
+ coerce_tests! %r{enums are distinct per class}
1284
+ test "enums are distinct per class coerced" do
1285
+ Book . connection . remove_index ( :books , column : [ :author_id , :name ] )
1286
+
1287
+ send ( :'original_enums are distinct per class' )
1288
+ ensure
1289
+ Book . connection . add_index ( :books , [ :author_id , :name ] , unique : true )
1290
+ end
1291
+
1292
+ # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1293
+ coerce_tests! %r{creating new objects with enum scopes}
1294
+ test "creating new objects with enum scopes coerced" do
1295
+ Book . connection . remove_index ( :books , column : [ :author_id , :name ] )
1296
+
1297
+ send ( :'original_creating new objects with enum scopes' )
1298
+ ensure
1299
+ Book . connection . add_index ( :books , [ :author_id , :name ] , unique : true )
1300
+ end
1301
+
1302
+ # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1303
+ coerce_tests! %r{enums are inheritable}
1304
+ test "enums are inheritable coerced" do
1305
+ Book . connection . remove_index ( :books , column : [ :author_id , :name ] )
1306
+
1307
+ send ( :'original_enums are inheritable' )
1308
+ ensure
1309
+ Book . connection . add_index ( :books , [ :author_id , :name ] , unique : true )
1310
+ end
1311
+
1312
+ # Need to remove index as SQL Server considers NULLs on a unique-index to be equal unlike PostgreSQL/MySQL/SQLite.
1313
+ coerce_tests! %r{declare multiple enums at a time}
1314
+ test "declare multiple enums at a time coerced" do
1315
+ Book . connection . remove_index ( :books , column : [ :author_id , :name ] )
1316
+
1317
+ send ( :'original_declare multiple enums at a time' )
1318
+ ensure
1319
+ Book . connection . add_index ( :books , [ :author_id , :name ] , unique : true )
1320
+ end
1321
+ end
0 commit comments