ibm_db 5.2.0-x86-mingw32 → 5.4.0-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGES +9 -0
 - data/LICENSE +55 -18
 - data/README +1 -1
 - data/debug.log +1 -0
 - data/ext/Makefile +28 -24
 - data/ext/ibm_db.c +66 -65
 - data/ext/ibm_db.o +0 -0
 - data/ext/ibm_db.so +0 -0
 - data/ext/mkmf.log +26 -24
 - data/ext/ruby_ibm_db_cli.c +1 -0
 - data/ext/ruby_ibm_db_cli.o +0 -0
 - data/lib/active_record/connection_adapters/ibm_db_adapter.rb +1520 -1282
 - data/lib/ibm_db.so +1 -0
 - data/lib/mswin32/ibm_db.rb +3 -1
 - data/lib/mswin32/rb3x/i386/ruby30/ibm_db.so +0 -0
 - data/lib/mswin32/rb3x/i386/ruby31/ibm_db.so +0 -0
 - data/test/active_record/connection_adapters/fake_adapter.rb +5 -2
 - data/test/activejob/destroy_association_async_test.rb +305 -0
 - data/test/activejob/destroy_async_job_not_present_test.rb +31 -0
 - data/test/activejob/helper.rb +15 -0
 - data/test/assets/schema_dump_5_1.yml +345 -0
 - data/test/cases/adapter_prevent_writes_test.rb +334 -0
 - data/test/cases/adapter_test.rb +432 -218
 - data/test/cases/adapters/mysql2/active_schema_test.rb +85 -75
 - data/test/cases/adapters/mysql2/auto_increment_test.rb +34 -0
 - data/test/cases/adapters/mysql2/bind_parameter_test.rb +5 -3
 - data/test/cases/adapters/mysql2/boolean_test.rb +6 -4
 - data/test/cases/adapters/mysql2/case_sensitivity_test.rb +26 -24
 - data/test/cases/adapters/mysql2/charset_collation_test.rb +20 -17
 - data/test/cases/adapters/mysql2/connection_test.rb +48 -50
 - data/test/cases/adapters/mysql2/count_deleted_rows_with_lock_test.rb +28 -0
 - data/test/cases/adapters/mysql2/datetime_precision_quoting_test.rb +23 -19
 - data/test/cases/adapters/mysql2/enum_test.rb +32 -11
 - data/test/cases/adapters/mysql2/explain_test.rb +13 -11
 - data/test/cases/adapters/mysql2/json_test.rb +17 -188
 - data/test/cases/adapters/mysql2/mysql2_adapter_prevent_writes_test.rb +208 -0
 - data/test/cases/adapters/mysql2/mysql2_adapter_test.rb +183 -28
 - data/test/cases/adapters/mysql2/nested_deadlock_test.rb +75 -0
 - data/test/cases/adapters/mysql2/optimizer_hints_test.rb +69 -0
 - data/test/cases/adapters/mysql2/schema_migrations_test.rb +26 -21
 - data/test/cases/adapters/mysql2/schema_test.rb +24 -22
 - data/test/cases/adapters/mysql2/set_test.rb +32 -0
 - data/test/cases/adapters/mysql2/sp_test.rb +10 -8
 - data/test/cases/adapters/mysql2/sql_types_test.rb +8 -6
 - data/test/cases/adapters/mysql2/table_options_test.rb +93 -10
 - data/test/cases/adapters/mysql2/transaction_test.rb +151 -0
 - data/test/cases/adapters/mysql2/unsigned_type_test.rb +11 -9
 - data/test/cases/adapters/mysql2/virtual_column_test.rb +66 -0
 - data/test/cases/adapters/postgresql/active_schema_test.rb +40 -25
 - data/test/cases/adapters/postgresql/array_test.rb +118 -63
 - data/test/cases/adapters/postgresql/bit_string_test.rb +12 -10
 - data/test/cases/adapters/postgresql/bytea_test.rb +26 -25
 - data/test/cases/adapters/postgresql/case_insensitive_test.rb +10 -9
 - data/test/cases/adapters/postgresql/change_schema_test.rb +7 -5
 - data/test/cases/adapters/postgresql/cidr_test.rb +2 -0
 - data/test/cases/adapters/postgresql/citext_test.rb +58 -58
 - data/test/cases/adapters/postgresql/collation_test.rb +17 -15
 - data/test/cases/adapters/postgresql/composite_test.rb +25 -23
 - data/test/cases/adapters/postgresql/connection_test.rb +73 -85
 - data/test/cases/adapters/postgresql/create_unlogged_tables_test.rb +74 -0
 - data/test/cases/adapters/postgresql/datatype_test.rb +19 -22
 - data/test/cases/adapters/postgresql/date_test.rb +42 -0
 - data/test/cases/adapters/postgresql/domain_test.rb +9 -7
 - data/test/cases/adapters/postgresql/enum_test.rb +12 -10
 - data/test/cases/adapters/postgresql/explain_test.rb +10 -8
 - data/test/cases/adapters/postgresql/extension_migration_test.rb +13 -12
 - data/test/cases/adapters/postgresql/foreign_table_test.rb +109 -0
 - data/test/cases/adapters/postgresql/full_text_test.rb +8 -6
 - data/test/cases/adapters/postgresql/geometric_test.rb +57 -63
 - data/test/cases/adapters/postgresql/hstore_test.rb +288 -280
 - data/test/cases/adapters/postgresql/infinity_test.rb +54 -15
 - data/test/cases/adapters/postgresql/integer_test.rb +2 -0
 - data/test/cases/adapters/postgresql/interval_test.rb +99 -0
 - data/test/cases/adapters/postgresql/json_test.rb +16 -201
 - data/test/cases/adapters/postgresql/ltree_test.rb +14 -16
 - data/test/cases/adapters/postgresql/money_test.rb +47 -16
 - data/test/cases/adapters/postgresql/network_test.rb +36 -28
 - data/test/cases/adapters/postgresql/numbers_test.rb +7 -5
 - data/test/cases/adapters/postgresql/optimizer_hints_test.rb +71 -0
 - data/test/cases/adapters/postgresql/partitions_test.rb +22 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_prevent_writes_test.rb +205 -0
 - data/test/cases/adapters/postgresql/postgresql_adapter_test.rb +178 -136
 - data/test/cases/adapters/postgresql/prepared_statements_disabled_test.rb +27 -0
 - data/test/cases/adapters/postgresql/quoting_test.rb +12 -6
 - data/test/cases/adapters/postgresql/range_test.rb +406 -292
 - data/test/cases/adapters/postgresql/referential_integrity_test.rb +16 -15
 - data/test/cases/adapters/postgresql/rename_table_test.rb +9 -8
 - data/test/cases/adapters/postgresql/schema_authorization_test.rb +14 -23
 - data/test/cases/adapters/postgresql/schema_test.rb +207 -91
 - data/test/cases/adapters/postgresql/serial_test.rb +9 -7
 - data/test/cases/adapters/postgresql/statement_pool_test.rb +26 -6
 - data/test/cases/adapters/postgresql/timestamp_test.rb +17 -15
 - data/test/cases/adapters/postgresql/transaction_nested_test.rb +114 -0
 - data/test/cases/adapters/postgresql/transaction_test.rb +189 -0
 - data/test/cases/adapters/postgresql/type_lookup_test.rb +12 -10
 - data/test/cases/adapters/postgresql/utils_test.rb +11 -9
 - data/test/cases/adapters/postgresql/uuid_test.rb +226 -109
 - data/test/cases/adapters/postgresql/xml_test.rb +10 -14
 - data/test/cases/adapters/sqlite3/collation_test.rb +26 -15
 - data/test/cases/adapters/sqlite3/copy_table_test.rb +31 -28
 - data/test/cases/adapters/sqlite3/explain_test.rb +13 -11
 - data/test/cases/adapters/sqlite3/json_test.rb +29 -0
 - data/test/cases/adapters/sqlite3/quoting_test.rb +35 -57
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_prevent_writes_test.rb +186 -0
 - data/test/cases/adapters/sqlite3/sqlite3_adapter_test.rb +318 -131
 - data/test/cases/adapters/sqlite3/sqlite3_create_folder_test.rb +11 -11
 - data/test/cases/adapters/sqlite3/statement_pool_test.rb +7 -6
 - data/test/cases/adapters/sqlite3/transaction_test.rb +123 -0
 - data/test/cases/aggregations_test.rb +14 -12
 - data/test/cases/annotate_test.rb +46 -0
 - data/test/cases/ar_schema_test.rb +153 -86
 - data/test/cases/arel/attributes/attribute_test.rb +1145 -0
 - data/test/cases/arel/attributes/math_test.rb +83 -0
 - data/test/cases/arel/attributes_test.rb +27 -0
 - data/test/cases/arel/collectors/bind_test.rb +40 -0
 - data/test/cases/arel/collectors/composite_test.rb +47 -0
 - data/test/cases/arel/collectors/sql_string_test.rb +41 -0
 - data/test/cases/arel/collectors/substitute_bind_collector_test.rb +48 -0
 - data/test/cases/arel/crud_test.rb +65 -0
 - data/test/cases/arel/delete_manager_test.rb +53 -0
 - data/test/cases/arel/factory_methods_test.rb +46 -0
 - data/test/cases/arel/helper.rb +45 -0
 - data/test/cases/arel/insert_manager_test.rb +241 -0
 - data/test/cases/arel/nodes/and_test.rb +30 -0
 - data/test/cases/arel/nodes/as_test.rb +36 -0
 - data/test/cases/arel/nodes/ascending_test.rb +46 -0
 - data/test/cases/arel/nodes/bin_test.rb +35 -0
 - data/test/cases/arel/nodes/binary_test.rb +29 -0
 - data/test/cases/arel/nodes/bind_param_test.rb +22 -0
 - data/test/cases/arel/nodes/case_test.rb +96 -0
 - data/test/cases/arel/nodes/casted_test.rb +18 -0
 - data/test/cases/arel/nodes/comment_test.rb +22 -0
 - data/test/cases/arel/nodes/count_test.rb +35 -0
 - data/test/cases/arel/nodes/delete_statement_test.rb +36 -0
 - data/test/cases/arel/nodes/descending_test.rb +46 -0
 - data/test/cases/arel/nodes/distinct_test.rb +21 -0
 - data/test/cases/arel/nodes/equality_test.rb +62 -0
 - data/test/cases/arel/nodes/extract_test.rb +43 -0
 - data/test/cases/arel/nodes/false_test.rb +21 -0
 - data/test/cases/arel/nodes/grouping_test.rb +26 -0
 - data/test/cases/arel/nodes/infix_operation_test.rb +42 -0
 - data/test/cases/arel/nodes/insert_statement_test.rb +44 -0
 - data/test/cases/arel/nodes/named_function_test.rb +48 -0
 - data/test/cases/arel/nodes/node_test.rb +22 -0
 - data/test/cases/arel/nodes/not_test.rb +31 -0
 - data/test/cases/arel/nodes/or_test.rb +36 -0
 - data/test/cases/arel/nodes/over_test.rb +69 -0
 - data/test/cases/arel/nodes/select_core_test.rb +79 -0
 - data/test/cases/arel/nodes/select_statement_test.rb +51 -0
 - data/test/cases/arel/nodes/sql_literal_test.rb +75 -0
 - data/test/cases/arel/nodes/sum_test.rb +35 -0
 - data/test/cases/arel/nodes/table_alias_test.rb +29 -0
 - data/test/cases/arel/nodes/true_test.rb +21 -0
 - data/test/cases/arel/nodes/unary_operation_test.rb +41 -0
 - data/test/cases/arel/nodes/update_statement_test.rb +60 -0
 - data/test/cases/arel/nodes/window_test.rb +81 -0
 - data/test/cases/arel/nodes_test.rb +34 -0
 - data/test/cases/arel/select_manager_test.rb +1238 -0
 - data/test/cases/arel/support/fake_record.rb +135 -0
 - data/test/cases/arel/table_test.rb +216 -0
 - data/test/cases/arel/update_manager_test.rb +126 -0
 - data/test/cases/arel/visitors/dispatch_contamination_test.rb +78 -0
 - data/test/cases/arel/visitors/dot_test.rb +90 -0
 - data/test/cases/arel/visitors/mysql_test.rb +157 -0
 - data/test/cases/arel/visitors/postgres_test.rb +366 -0
 - data/test/cases/arel/visitors/sqlite_test.rb +75 -0
 - data/test/cases/arel/visitors/to_sql_test.rb +750 -0
 - data/test/cases/associations/belongs_to_associations_test.rb +510 -158
 - data/test/cases/associations/bidirectional_destroy_dependencies_test.rb +4 -2
 - data/test/cases/associations/callbacks_test.rb +56 -38
 - data/test/cases/associations/cascaded_eager_loading_test.rb +118 -61
 - data/test/cases/associations/eager_load_includes_full_sti_class_test.rb +138 -18
 - data/test/cases/associations/eager_load_nested_include_test.rb +38 -37
 - data/test/cases/associations/eager_singularization_test.rb +21 -21
 - data/test/cases/associations/eager_test.rb +559 -415
 - data/test/cases/associations/extension_test.rb +18 -12
 - data/test/cases/associations/has_and_belongs_to_many_associations_test.rb +234 -213
 - data/test/cases/associations/has_many_associations_test.rb +1038 -465
 - data/test/cases/associations/has_many_through_associations_test.rb +558 -249
 - data/test/cases/associations/has_one_associations_test.rb +294 -129
 - data/test/cases/associations/has_one_through_associations_test.rb +121 -75
 - data/test/cases/associations/inner_join_association_test.rb +114 -38
 - data/test/cases/associations/inverse_associations_test.rb +606 -398
 - data/test/cases/associations/join_model_test.rb +158 -148
 - data/test/cases/associations/left_outer_join_association_test.rb +59 -24
 - data/test/cases/associations/nested_through_associations_test.rb +166 -109
 - data/test/cases/associations/required_test.rb +35 -10
 - data/test/cases/associations_test.rb +241 -110
 - data/test/cases/attribute_methods/read_test.rb +11 -11
 - data/test/cases/attribute_methods_test.rb +413 -298
 - data/test/cases/attributes_test.rb +145 -27
 - data/test/cases/autosave_association_test.rb +681 -436
 - data/test/cases/base_prevent_writes_test.rb +229 -0
 - data/test/cases/base_test.rb +599 -542
 - data/test/cases/batches_test.rb +288 -82
 - data/test/cases/binary_test.rb +26 -31
 - data/test/cases/bind_parameter_test.rb +194 -21
 - data/test/cases/boolean_test.rb +52 -0
 - data/test/cases/cache_key_test.rb +110 -5
 - data/test/cases/calculations_test.rb +740 -177
 - data/test/cases/callbacks_test.rb +74 -207
 - data/test/cases/clone_test.rb +15 -10
 - data/test/cases/coders/json_test.rb +2 -0
 - data/test/cases/coders/yaml_column_test.rb +16 -13
 - data/test/cases/collection_cache_key_test.rb +177 -20
 - data/test/cases/column_alias_test.rb +9 -7
 - data/test/cases/column_definition_test.rb +10 -68
 - data/test/cases/comment_test.rb +166 -107
 - data/test/cases/connection_adapters/adapter_leasing_test.rb +14 -10
 - data/test/cases/connection_adapters/connection_handler_test.rb +358 -51
 - data/test/cases/connection_adapters/connection_handlers_multi_db_test.rb +400 -0
 - data/test/cases/connection_adapters/connection_handlers_multi_pool_config_test.rb +103 -0
 - data/test/cases/connection_adapters/connection_handlers_sharding_db_test.rb +499 -0
 - data/test/cases/connection_adapters/connection_swapping_nested_test.rb +457 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_multi_db_test.rb +486 -0
 - data/test/cases/connection_adapters/legacy_connection_handlers_sharding_db_test.rb +586 -0
 - data/test/cases/connection_adapters/merge_and_resolve_default_url_config_test.rb +319 -138
 - data/test/cases/connection_adapters/mysql_type_lookup_test.rb +62 -50
 - data/test/cases/connection_adapters/schema_cache_test.rb +259 -26
 - data/test/cases/connection_adapters/type_lookup_test.rb +96 -95
 - data/test/cases/connection_management_test.rb +13 -11
 - data/test/cases/connection_pool_test.rb +316 -83
 - data/test/cases/core_test.rb +82 -58
 - data/test/cases/counter_cache_test.rb +204 -50
 - data/test/cases/custom_locking_test.rb +5 -3
 - data/test/cases/database_configurations/hash_config_test.rb +74 -0
 - data/test/cases/database_configurations/resolver_test.rb +150 -0
 - data/test/cases/database_configurations_test.rb +145 -0
 - data/test/cases/database_selector_test.rb +296 -0
 - data/test/cases/database_statements_test.rb +18 -16
 - data/test/cases/date_test.rb +8 -16
 - data/test/cases/date_time_precision_test.rb +100 -78
 - data/test/cases/date_time_test.rb +23 -8
 - data/test/cases/defaults_test.rb +106 -71
 - data/test/cases/delegated_type_test.rb +57 -0
 - data/test/cases/dirty_test.rb +419 -223
 - data/test/cases/disconnected_test.rb +6 -6
 - data/test/cases/dup_test.rb +54 -27
 - data/test/cases/enum_test.rb +461 -82
 - data/test/cases/errors_test.rb +7 -7
 - data/test/cases/explain_subscriber_test.rb +17 -15
 - data/test/cases/explain_test.rb +11 -19
 - data/test/cases/filter_attributes_test.rb +153 -0
 - data/test/cases/finder_respond_to_test.rb +14 -14
 - data/test/cases/finder_test.rb +669 -287
 - data/test/cases/fixture_set/file_test.rb +34 -38
 - data/test/cases/fixtures_test.rb +833 -176
 - data/test/cases/forbidden_attributes_protection_test.rb +32 -67
 - data/test/cases/habtm_destroy_order_test.rb +25 -25
 - data/test/cases/helper.rb +78 -49
 - data/test/cases/hot_compatibility_test.rb +33 -32
 - data/test/cases/i18n_test.rb +18 -17
 - data/test/cases/inheritance_test.rb +180 -115
 - data/test/cases/insert_all_test.rb +489 -0
 - data/test/cases/instrumentation_test.rb +101 -0
 - data/test/cases/integration_test.rb +119 -31
 - data/test/cases/invalid_connection_test.rb +18 -16
 - data/test/cases/invertible_migration_test.rb +183 -43
 - data/test/cases/json_attribute_test.rb +35 -0
 - data/test/cases/json_serialization_test.rb +57 -58
 - data/test/cases/json_shared_test_cases.rb +290 -0
 - data/test/cases/locking_test.rb +413 -119
 - data/test/cases/log_subscriber_test.rb +68 -26
 - data/test/cases/marshal_serialization_test.rb +39 -0
 - data/test/cases/migration/change_schema_test.rb +118 -72
 - data/test/cases/migration/change_table_test.rb +138 -30
 - data/test/cases/migration/check_constraint_test.rb +162 -0
 - data/test/cases/migration/column_attributes_test.rb +45 -35
 - data/test/cases/migration/column_positioning_test.rb +18 -6
 - data/test/cases/migration/columns_test.rb +93 -77
 - data/test/cases/migration/command_recorder_test.rb +121 -34
 - data/test/cases/migration/compatibility_test.rb +578 -23
 - data/test/cases/migration/create_join_table_test.rb +35 -25
 - data/test/cases/migration/foreign_key_test.rb +503 -284
 - data/test/cases/migration/helper.rb +4 -3
 - data/test/cases/migration/index_test.rb +119 -70
 - data/test/cases/migration/logger_test.rb +9 -6
 - data/test/cases/migration/pending_migrations_test.rb +88 -34
 - data/test/cases/migration/references_foreign_key_test.rb +164 -150
 - data/test/cases/migration/references_index_test.rb +38 -19
 - data/test/cases/migration/references_statements_test.rb +15 -14
 - data/test/cases/migration/rename_table_test.rb +53 -30
 - data/test/cases/migration_test.rb +637 -269
 - data/test/cases/migrator_test.rb +191 -135
 - data/test/cases/mixin_test.rb +7 -11
 - data/test/cases/modules_test.rb +36 -34
 - data/test/cases/multi_db_migrator_test.rb +223 -0
 - data/test/cases/multiparameter_attributes_test.rb +60 -33
 - data/test/cases/multiple_db_test.rb +16 -22
 - data/test/cases/nested_attributes_test.rb +341 -320
 - data/test/cases/nested_attributes_with_callbacks_test.rb +26 -24
 - data/test/cases/null_relation_test.rb +84 -0
 - data/test/cases/numeric_data_test.rb +93 -0
 - data/test/cases/persistence_test.rb +361 -269
 - data/test/cases/pooled_connections_test.rb +18 -26
 - data/test/cases/prepared_statement_status_test.rb +48 -0
 - data/test/cases/primary_keys_test.rb +210 -104
 - data/test/cases/query_cache_test.rb +610 -141
 - data/test/cases/quoting_test.rb +132 -31
 - data/test/cases/readonly_test.rb +49 -48
 - data/test/cases/reaper_test.rb +146 -32
 - data/test/cases/reflection_test.rb +167 -156
 - data/test/cases/relation/delegation_test.rb +49 -36
 - data/test/cases/relation/delete_all_test.rb +117 -0
 - data/test/cases/relation/merging_test.rb +319 -42
 - data/test/cases/relation/mutation_test.rb +55 -93
 - data/test/cases/relation/or_test.rb +129 -29
 - data/test/cases/relation/predicate_builder_test.rb +21 -6
 - data/test/cases/relation/record_fetch_warning_test.rb +5 -3
 - data/test/cases/relation/select_test.rb +67 -0
 - data/test/cases/relation/update_all_test.rb +317 -0
 - data/test/cases/relation/where_chain_test.rb +68 -32
 - data/test/cases/relation/where_clause_test.rb +136 -61
 - data/test/cases/relation/where_test.rb +155 -48
 - data/test/cases/relation_test.rb +266 -112
 - data/test/cases/relations_test.rb +969 -744
 - data/test/cases/reload_models_test.rb +13 -9
 - data/test/cases/reserved_word_test.rb +141 -0
 - data/test/cases/result_test.rb +68 -17
 - data/test/cases/sanitize_test.rb +87 -71
 - data/test/cases/schema_dumper_test.rb +221 -128
 - data/test/cases/schema_loading_test.rb +3 -2
 - data/test/cases/scoping/default_scoping_test.rb +185 -144
 - data/test/cases/scoping/named_scoping_test.rb +177 -89
 - data/test/cases/scoping/relation_scoping_test.rb +197 -75
 - data/test/cases/secure_token_test.rb +18 -3
 - data/test/cases/serialization_test.rb +30 -28
 - data/test/cases/serialized_attribute_test.rb +133 -42
 - data/test/cases/signed_id_test.rb +168 -0
 - data/test/cases/statement_cache_test.rb +41 -24
 - data/test/cases/statement_invalid_test.rb +42 -0
 - data/test/cases/store_test.rb +180 -55
 - data/test/cases/strict_loading_test.rb +473 -0
 - data/test/cases/suppressor_test.rb +26 -12
 - data/test/cases/tasks/database_tasks_test.rb +1258 -194
 - data/test/cases/tasks/mysql_rake_test.rb +370 -298
 - data/test/cases/tasks/postgresql_rake_test.rb +481 -251
 - data/test/cases/tasks/sqlite_rake_test.rb +225 -178
 - data/test/cases/test_case.rb +51 -40
 - data/test/cases/test_databases_test.rb +79 -0
 - data/test/cases/test_fixtures_test.rb +79 -19
 - data/test/cases/time_precision_test.rb +98 -76
 - data/test/cases/timestamp_test.rb +102 -99
 - data/test/cases/touch_later_test.rb +12 -10
 - data/test/cases/transaction_callbacks_test.rb +344 -90
 - data/test/cases/transaction_isolation_test.rb +12 -12
 - data/test/cases/transactions_test.rb +612 -162
 - data/test/cases/type/adapter_specific_registry_test.rb +14 -2
 - data/test/cases/type/date_time_test.rb +4 -2
 - data/test/cases/type/integer_test.rb +4 -2
 - data/test/cases/type/string_test.rb +10 -8
 - data/test/cases/type/time_test.rb +28 -0
 - data/test/cases/type/type_map_test.rb +29 -28
 - data/test/cases/type/unsigned_integer_test.rb +19 -0
 - data/test/cases/type_test.rb +2 -0
 - data/test/cases/types_test.rb +3 -1
 - data/test/cases/unconnected_test.rb +14 -1
 - data/test/cases/unsafe_raw_sql_test.rb +274 -0
 - data/test/cases/validations/absence_validation_test.rb +19 -17
 - data/test/cases/validations/association_validation_test.rb +30 -28
 - data/test/cases/validations/i18n_generate_message_validation_test.rb +34 -16
 - data/test/cases/validations/i18n_validation_test.rb +22 -21
 - data/test/cases/validations/length_validation_test.rb +34 -33
 - data/test/cases/validations/numericality_validation_test.rb +181 -0
 - data/test/cases/validations/presence_validation_test.rb +21 -19
 - data/test/cases/validations/uniqueness_validation_test.rb +156 -86
 - data/test/cases/validations_repair_helper.rb +2 -0
 - data/test/cases/validations_test.rb +61 -26
 - data/test/cases/view_test.rb +122 -116
 - data/test/cases/yaml_serialization_test.rb +79 -34
 - data/test/config.example.yml +19 -19
 - data/test/config.rb +3 -1
 - data/test/config.yml +16 -6
 - data/test/fixtures/all/namespaced/accounts.yml +2 -0
 - data/test/fixtures/author_addresses.yml +1 -8
 - data/test/fixtures/authors.yml +1 -7
 - data/test/fixtures/binaries.yml +4 -0
 - data/test/fixtures/books.yml +9 -2
 - data/test/fixtures/categories_posts.yml +3 -0
 - data/test/fixtures/citations.yml +5 -0
 - data/test/fixtures/comments.yml +7 -0
 - data/test/fixtures/companies.yml +5 -0
 - data/test/fixtures/computers.yml +2 -0
 - data/test/fixtures/customers.yml +10 -1
 - data/test/fixtures/developers.yml +1 -1
 - data/test/fixtures/essays.yml +10 -0
 - data/test/fixtures/faces.yml +3 -3
 - data/test/fixtures/humans.yml +5 -0
 - data/test/fixtures/interests.yml +7 -7
 - data/test/fixtures/memberships.yml +7 -0
 - data/test/fixtures/minimalistics.yml +3 -0
 - data/test/fixtures/mixed_case_monkeys.yml +2 -2
 - data/test/fixtures/naked/yml/courses_with_invalid_key.yml +3 -0
 - data/test/fixtures/naked/yml/parrots.yml +1 -0
 - data/test/fixtures/other_books.yml +26 -0
 - data/test/fixtures/other_posts.yml +1 -0
 - data/test/fixtures/parrots.yml +7 -1
 - data/test/fixtures/pirates.yml +3 -0
 - data/test/fixtures/posts.yml +11 -3
 - data/test/fixtures/readers.yml +6 -0
 - data/test/fixtures/reserved_words/values.yml +2 -2
 - data/test/fixtures/sponsors.yml +3 -0
 - data/test/fixtures/strict_zines.yml +2 -0
 - data/test/fixtures/subscribers.yml +1 -1
 - data/test/fixtures/tasks.yml +1 -1
 - data/test/fixtures/warehouse-things.yml +3 -0
 - data/test/migrations/10_urban/9_add_expressions.rb +2 -0
 - data/test/migrations/decimal/1_give_me_big_numbers.rb +6 -4
 - data/test/migrations/magic/1_currencies_have_symbols.rb +3 -2
 - data/test/migrations/missing/1000_people_have_middle_names.rb +2 -0
 - data/test/migrations/missing/1_people_have_last_names.rb +2 -0
 - data/test/migrations/missing/3_we_need_reminders.rb +2 -0
 - data/test/migrations/missing/4_innocent_jointable.rb +3 -1
 - data/test/migrations/rename/1_we_need_things.rb +2 -0
 - data/test/migrations/rename/2_rename_things.rb +2 -0
 - data/test/migrations/to_copy/1_people_have_hobbies.rb +3 -1
 - data/test/migrations/to_copy/2_people_have_descriptions.rb +3 -1
 - data/test/migrations/to_copy2/1_create_articles.rb +2 -0
 - data/test/migrations/to_copy2/2_create_comments.rb +3 -1
 - data/test/migrations/to_copy_with_name_collision/1_people_have_hobbies.rb +3 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010101_people_have_hobbies.rb +3 -1
 - data/test/migrations/to_copy_with_timestamps/20090101010202_people_have_descriptions.rb +3 -1
 - data/test/migrations/to_copy_with_timestamps2/20090101010101_create_articles.rb +2 -0
 - data/test/migrations/to_copy_with_timestamps2/20090101010202_create_comments.rb +2 -0
 - data/test/migrations/valid/1_valid_people_have_last_names.rb +2 -0
 - data/test/migrations/valid/2_we_need_reminders.rb +2 -0
 - data/test/migrations/valid/3_innocent_jointable.rb +3 -1
 - data/test/migrations/valid_with_subdirectories/1_valid_people_have_last_names.rb +2 -0
 - data/test/migrations/valid_with_subdirectories/sub/2_we_need_reminders.rb +2 -0
 - data/test/migrations/valid_with_subdirectories/sub1/3_innocent_jointable.rb +3 -1
 - data/test/migrations/valid_with_timestamps/20100101010101_valid_with_timestamps_people_have_last_names.rb +2 -0
 - data/test/migrations/valid_with_timestamps/20100201010101_valid_with_timestamps_we_need_reminders.rb +2 -0
 - data/test/migrations/valid_with_timestamps/20100301010101_valid_with_timestamps_innocent_jointable.rb +3 -1
 - data/test/migrations/version_check/20131219224947_migration_version_check.rb +2 -0
 - data/test/models/account.rb +46 -0
 - data/test/models/admin/account.rb +3 -1
 - data/test/models/admin/randomly_named_c1.rb +2 -0
 - data/test/models/admin/user.rb +16 -8
 - data/test/models/admin.rb +4 -2
 - data/test/models/aircraft.rb +3 -1
 - data/test/models/arunit2_model.rb +2 -0
 - data/test/models/author.rb +153 -102
 - data/test/models/auto_id.rb +2 -0
 - data/test/models/autoloadable/extra_firm.rb +2 -0
 - data/test/models/binary.rb +3 -1
 - data/test/models/binary_field.rb +6 -0
 - data/test/models/bird.rb +13 -1
 - data/test/models/book.rb +14 -4
 - data/test/models/book_destroy_async.rb +24 -0
 - data/test/models/boolean.rb +5 -0
 - data/test/models/bulb.rb +13 -4
 - data/test/models/cake_designer.rb +2 -0
 - data/test/models/car.rb +17 -10
 - data/test/models/carrier.rb +2 -0
 - data/test/models/cart.rb +5 -0
 - data/test/models/cat.rb +2 -0
 - data/test/models/categorization.rb +8 -6
 - data/test/models/category.rb +28 -16
 - data/test/models/chef.rb +2 -0
 - data/test/models/citation.rb +5 -1
 - data/test/models/club.rb +13 -10
 - data/test/models/college.rb +4 -2
 - data/test/models/column.rb +2 -0
 - data/test/models/column_name.rb +2 -0
 - data/test/models/comment.rb +32 -10
 - data/test/models/company.rb +102 -106
 - data/test/models/company_in_module.rb +27 -26
 - data/test/models/computer.rb +3 -1
 - data/test/models/contact.rb +15 -13
 - data/test/models/content.rb +5 -3
 - data/test/models/contract.rb +21 -3
 - data/test/models/country.rb +2 -4
 - data/test/models/course.rb +3 -1
 - data/test/models/customer.rb +10 -8
 - data/test/models/customer_carrier.rb +2 -0
 - data/test/models/dashboard.rb +2 -0
 - data/test/models/default.rb +2 -0
 - data/test/models/department.rb +2 -0
 - data/test/models/destroy_async_parent.rb +15 -0
 - data/test/models/destroy_async_parent_soft_delete.rb +20 -0
 - data/test/models/developer.rb +152 -85
 - data/test/models/dl_keyed_belongs_to.rb +13 -0
 - data/test/models/dl_keyed_belongs_to_soft_delete.rb +19 -0
 - data/test/models/dl_keyed_has_many.rb +5 -0
 - data/test/models/dl_keyed_has_many_through.rb +5 -0
 - data/test/models/dl_keyed_has_one.rb +5 -0
 - data/test/models/dl_keyed_join.rb +10 -0
 - data/test/models/dog.rb +2 -0
 - data/test/models/dog_lover.rb +2 -0
 - data/test/models/doubloon.rb +3 -1
 - data/test/models/drink_designer.rb +17 -0
 - data/test/models/edge.rb +4 -2
 - data/test/models/electron.rb +2 -0
 - data/test/models/engine.rb +3 -2
 - data/test/models/entrant.rb +2 -0
 - data/test/models/entry.rb +5 -0
 - data/test/models/essay.rb +6 -3
 - data/test/models/essay_destroy_async.rb +12 -0
 - data/test/models/event.rb +3 -1
 - data/test/models/eye.rb +5 -3
 - data/test/models/face.rb +14 -6
 - data/test/models/family.rb +6 -0
 - data/test/models/family_tree.rb +6 -0
 - data/test/models/friendship.rb +5 -3
 - data/test/models/frog.rb +8 -0
 - data/test/models/guid.rb +3 -1
 - data/test/models/guitar.rb +2 -0
 - data/test/models/hotel.rb +5 -3
 - data/test/models/human.rb +39 -0
 - data/test/models/image.rb +3 -1
 - data/test/models/interest.rb +14 -3
 - data/test/models/invoice.rb +4 -2
 - data/test/models/item.rb +3 -1
 - data/test/models/job.rb +5 -3
 - data/test/models/joke.rb +4 -2
 - data/test/models/keyboard.rb +3 -1
 - data/test/models/legacy_thing.rb +2 -0
 - data/test/models/lesson.rb +2 -0
 - data/test/models/line_item.rb +3 -1
 - data/test/models/liquid.rb +2 -0
 - data/test/models/matey.rb +3 -1
 - data/test/models/measurement.rb +4 -0
 - data/test/models/member.rb +23 -20
 - data/test/models/member_detail.rb +3 -0
 - data/test/models/member_type.rb +2 -0
 - data/test/models/membership.rb +4 -1
 - data/test/models/mentor.rb +3 -1
 - data/test/models/message.rb +5 -0
 - data/test/models/minimalistic.rb +2 -0
 - data/test/models/minivan.rb +3 -2
 - data/test/models/mixed_case_monkey.rb +3 -1
 - data/test/models/molecule.rb +2 -0
 - data/test/models/mouse.rb +6 -0
 - data/test/models/movie.rb +2 -0
 - data/test/models/node.rb +4 -2
 - data/test/models/non_primary_key.rb +2 -0
 - data/test/models/notification.rb +2 -0
 - data/test/models/numeric_data.rb +12 -0
 - data/test/models/order.rb +4 -2
 - data/test/models/organization.rb +9 -7
 - data/test/models/other_dog.rb +3 -1
 - data/test/models/owner.rb +6 -4
 - data/test/models/parrot.rb +12 -4
 - data/test/models/person.rb +59 -54
 - data/test/models/personal_legacy_thing.rb +3 -1
 - data/test/models/pet.rb +4 -2
 - data/test/models/pet_treasure.rb +2 -0
 - data/test/models/pirate.rb +67 -43
 - data/test/models/possession.rb +3 -1
 - data/test/models/post.rb +184 -86
 - data/test/models/price_estimate.rb +11 -1
 - data/test/models/professor.rb +3 -1
 - data/test/models/project.rb +14 -12
 - data/test/models/publisher/article.rb +2 -0
 - data/test/models/publisher/magazine.rb +2 -0
 - data/test/models/publisher.rb +2 -0
 - data/test/models/randomly_named_c1.rb +2 -0
 - data/test/models/rating.rb +5 -1
 - data/test/models/reader.rb +7 -5
 - data/test/models/recipe.rb +2 -0
 - data/test/models/record.rb +2 -0
 - data/test/models/reference.rb +6 -3
 - data/test/models/reply.rb +39 -21
 - data/test/models/room.rb +6 -0
 - data/test/models/section.rb +6 -0
 - data/test/models/seminar.rb +6 -0
 - data/test/models/session.rb +6 -0
 - data/test/models/ship.rb +12 -9
 - data/test/models/ship_part.rb +5 -3
 - data/test/models/shop.rb +4 -2
 - data/test/models/shop_account.rb +2 -0
 - data/test/models/speedometer.rb +2 -0
 - data/test/models/sponsor.rb +8 -5
 - data/test/models/squeak.rb +6 -0
 - data/test/models/strict_zine.rb +7 -0
 - data/test/models/string_key_object.rb +2 -0
 - data/test/models/student.rb +2 -0
 - data/test/models/subscriber.rb +4 -2
 - data/test/models/subscription.rb +5 -1
 - data/test/models/tag.rb +6 -3
 - data/test/models/tagging.rb +13 -6
 - data/test/models/task.rb +2 -0
 - data/test/models/topic.rb +54 -19
 - data/test/models/toy.rb +4 -0
 - data/test/models/traffic_light.rb +2 -0
 - data/test/models/treasure.rb +5 -3
 - data/test/models/treaty.rb +2 -4
 - data/test/models/tree.rb +2 -0
 - data/test/models/tuning_peg.rb +2 -0
 - data/test/models/tyre.rb +2 -0
 - data/test/models/user.rb +12 -4
 - data/test/models/uuid_child.rb +2 -0
 - data/test/models/uuid_item.rb +2 -0
 - data/test/models/uuid_parent.rb +2 -0
 - data/test/models/vegetables.rb +12 -3
 - data/test/models/vertex.rb +6 -4
 - data/test/models/warehouse_thing.rb +2 -0
 - data/test/models/wheel.rb +3 -1
 - data/test/models/without_table.rb +3 -1
 - data/test/models/zine.rb +3 -1
 - data/test/schema/mysql2_specific_schema.rb +49 -35
 - data/test/schema/oracle_specific_schema.rb +13 -15
 - data/test/schema/postgresql_specific_schema.rb +51 -40
 - data/test/schema/schema.rb +334 -154
 - data/test/schema/sqlite_specific_schema.rb +9 -16
 - data/test/support/config.rb +26 -26
 - data/test/support/connection.rb +14 -8
 - data/test/support/connection_helper.rb +3 -1
 - data/test/support/ddl_helper.rb +2 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/IBM_DB/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/Mysql2/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/PostgreSQL/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/SQLite/rails_6_0_topic_associations.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_6_0_record_mysql.dump +0 -0
 - data/test/support/marshal_compatibility_fixtures/legacy_relation.dump +0 -0
 - data/test/support/schema_dumping_helper.rb +2 -0
 - data/test/support/stubs/strong_parameters.rb +40 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v1_mysql.yml +206 -0
 - data/test/support/yaml_compatibility_fixtures/rails_v2.yml +55 -0
 - metadata +192 -14
 
    
        data/test/cases/fixtures_test.rb
    CHANGED
    
    | 
         @@ -1,46 +1,59 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            require  
     | 
| 
       4 
     | 
    
         
            -
            require  
     | 
| 
       5 
     | 
    
         
            -
            require  
     | 
| 
       6 
     | 
    
         
            -
            require  
     | 
| 
       7 
     | 
    
         
            -
            require  
     | 
| 
       8 
     | 
    
         
            -
            require  
     | 
| 
       9 
     | 
    
         
            -
            require  
     | 
| 
       10 
     | 
    
         
            -
            require  
     | 
| 
       11 
     | 
    
         
            -
            require  
     | 
| 
       12 
     | 
    
         
            -
            require  
     | 
| 
       13 
     | 
    
         
            -
            require  
     | 
| 
       14 
     | 
    
         
            -
            require  
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require "cases/helper"
         
     | 
| 
      
 4 
     | 
    
         
            +
            require "support/connection_helper"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require "models/admin"
         
     | 
| 
      
 6 
     | 
    
         
            +
            require "models/admin/account"
         
     | 
| 
      
 7 
     | 
    
         
            +
            require "models/admin/randomly_named_c1"
         
     | 
| 
      
 8 
     | 
    
         
            +
            require "models/admin/user"
         
     | 
| 
      
 9 
     | 
    
         
            +
            require "models/binary"
         
     | 
| 
      
 10 
     | 
    
         
            +
            require "models/book"
         
     | 
| 
      
 11 
     | 
    
         
            +
            require "models/bulb"
         
     | 
| 
      
 12 
     | 
    
         
            +
            require "models/category"
         
     | 
| 
      
 13 
     | 
    
         
            +
            require "models/post"
         
     | 
| 
      
 14 
     | 
    
         
            +
            require "models/comment"
         
     | 
| 
      
 15 
     | 
    
         
            +
            require "models/company"
         
     | 
| 
      
 16 
     | 
    
         
            +
            require "models/computer"
         
     | 
| 
      
 17 
     | 
    
         
            +
            require "models/course"
         
     | 
| 
      
 18 
     | 
    
         
            +
            require "models/developer"
         
     | 
| 
       15 
19 
     | 
    
         
             
            require "models/dog"
         
     | 
| 
       16 
     | 
    
         
            -
            require  
     | 
| 
       17 
     | 
    
         
            -
            require  
     | 
| 
       18 
     | 
    
         
            -
            require  
     | 
| 
      
 20 
     | 
    
         
            +
            require "models/doubloon"
         
     | 
| 
      
 21 
     | 
    
         
            +
            require "models/joke"
         
     | 
| 
      
 22 
     | 
    
         
            +
            require "models/matey"
         
     | 
| 
       19 
23 
     | 
    
         
             
            require "models/other_dog"
         
     | 
| 
       20 
     | 
    
         
            -
            require  
     | 
| 
       21 
     | 
    
         
            -
            require  
     | 
| 
       22 
     | 
    
         
            -
            require  
     | 
| 
       23 
     | 
    
         
            -
            require  
     | 
| 
       24 
     | 
    
         
            -
            require  
     | 
| 
       25 
     | 
    
         
            -
            require  
     | 
| 
       26 
     | 
    
         
            -
            require  
     | 
| 
       27 
     | 
    
         
            -
            require  
     | 
| 
       28 
     | 
    
         
            -
            require  
     | 
| 
       29 
     | 
    
         
            -
            require  
     | 
| 
       30 
     | 
    
         
            -
            require 'tempfile'
         
     | 
| 
      
 24 
     | 
    
         
            +
            require "models/parrot"
         
     | 
| 
      
 25 
     | 
    
         
            +
            require "models/pirate"
         
     | 
| 
      
 26 
     | 
    
         
            +
            require "models/randomly_named_c1"
         
     | 
| 
      
 27 
     | 
    
         
            +
            require "models/reply"
         
     | 
| 
      
 28 
     | 
    
         
            +
            require "models/ship"
         
     | 
| 
      
 29 
     | 
    
         
            +
            require "models/task"
         
     | 
| 
      
 30 
     | 
    
         
            +
            require "models/topic"
         
     | 
| 
      
 31 
     | 
    
         
            +
            require "models/traffic_light"
         
     | 
| 
      
 32 
     | 
    
         
            +
            require "models/treasure"
         
     | 
| 
      
 33 
     | 
    
         
            +
            require "tempfile"
         
     | 
| 
       31 
34 
     | 
    
         | 
| 
       32 
35 
     | 
    
         
             
            class FixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 36 
     | 
    
         
            +
              include ConnectionHelper
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
       33 
38 
     | 
    
         
             
              self.use_instantiated_fixtures = true
         
     | 
| 
       34 
39 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       35 
40 
     | 
    
         | 
| 
       36 
41 
     | 
    
         
             
              # other_topics fixture should not be included here
         
     | 
| 
       37 
     | 
    
         
            -
              fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights
         
     | 
| 
      
 42 
     | 
    
         
            +
              fixtures :topics, :developers, :accounts, :tasks, :categories, :funny_jokes, :binaries, :traffic_lights, :treasures
         
     | 
| 
       38 
43 
     | 
    
         | 
| 
       39 
44 
     | 
    
         
             
              FIXTURES = %w( accounts binaries companies customers
         
     | 
| 
       40 
45 
     | 
    
         
             
                             developers developers_projects entrants
         
     | 
| 
       41 
46 
     | 
    
         
             
                             movies projects subscribers topics tasks )
         
     | 
| 
       42 
47 
     | 
    
         
             
              MATCH_ATTRIBUTE_NAME = /[a-zA-Z][-\w]*/
         
     | 
| 
       43 
48 
     | 
    
         | 
| 
      
 49 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 50 
     | 
    
         
            +
                Arel::Table.engine = nil # should not rely on the global Arel::Table.engine
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 54 
     | 
    
         
            +
                Arel::Table.engine = ActiveRecord::Base
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
       44 
57 
     | 
    
         
             
              def test_clean_fixtures
         
     | 
| 
       45 
58 
     | 
    
         
             
                FIXTURES.each do |name|
         
     | 
| 
       46 
59 
     | 
    
         
             
                  fixtures = nil
         
     | 
| 
         @@ -54,13 +67,251 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       54 
67 
     | 
    
         
             
                end
         
     | 
| 
       55 
68 
     | 
    
         
             
              end
         
     | 
| 
       56 
69 
     | 
    
         | 
| 
      
 70 
     | 
    
         
            +
              class InsertQuerySubscriber
         
     | 
| 
      
 71 
     | 
    
         
            +
                attr_reader :events
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                def initialize
         
     | 
| 
      
 74 
     | 
    
         
            +
                  @events = []
         
     | 
| 
      
 75 
     | 
    
         
            +
                end
         
     | 
| 
      
 76 
     | 
    
         
            +
             
     | 
| 
      
 77 
     | 
    
         
            +
                def call(_, _, _, _, values)
         
     | 
| 
      
 78 
     | 
    
         
            +
                  @events << values[:sql] if /INSERT/.match?(values[:sql])
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
              end
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter, :PostgreSQLAdapter)
         
     | 
| 
      
 83 
     | 
    
         
            +
                def test_bulk_insert
         
     | 
| 
      
 84 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 85 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 86 
     | 
    
         
            +
                  create_fixtures("bulbs")
         
     | 
| 
      
 87 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size, "It takes one INSERT query to insert two fixtures"
         
     | 
| 
      
 88 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 89 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 90 
     | 
    
         
            +
                end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                def test_bulk_insert_multiple_table_with_a_multi_statement_query
         
     | 
| 
      
 93 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 94 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
                  create_fixtures("bulbs", "authors", "computers")
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  expected_sql = <<~EOS.chop
         
     | 
| 
      
 99 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("bulbs")} .*
         
     | 
| 
      
 100 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("authors")} .*
         
     | 
| 
      
 101 
     | 
    
         
            +
                    INSERT INTO #{ActiveRecord::Base.connection.quote_table_name("computers")} .*
         
     | 
| 
      
 102 
     | 
    
         
            +
                  EOS
         
     | 
| 
      
 103 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size
         
     | 
| 
      
 104 
     | 
    
         
            +
                  assert_match(/#{expected_sql}/, subscriber.events.first)
         
     | 
| 
      
 105 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 106 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                def test_bulk_insert_with_a_multi_statement_query_raises_an_exception_when_any_insert_fails
         
     | 
| 
      
 110 
     | 
    
         
            +
                  require "models/aircraft"
         
     | 
| 
      
 111 
     | 
    
         
            +
             
     | 
| 
      
 112 
     | 
    
         
            +
                  assert_equal false, Aircraft.columns_hash["wheels_count"].null
         
     | 
| 
      
 113 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 114 
     | 
    
         
            +
                    "aircraft" => [
         
     | 
| 
      
 115 
     | 
    
         
            +
                      { "name" => "working_aircrafts", "wheels_count" => 2 },
         
     | 
| 
      
 116 
     | 
    
         
            +
                      { "name" => "broken_aircrafts", "wheels_count" => nil },
         
     | 
| 
      
 117 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 118 
     | 
    
         
            +
                  }
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                  assert_no_difference "Aircraft.count" do
         
     | 
| 
      
 121 
     | 
    
         
            +
                    assert_raises(ActiveRecord::NotNullViolation) do
         
     | 
| 
      
 122 
     | 
    
         
            +
                      ActiveRecord::Base.connection.insert_fixtures_set(fixtures)
         
     | 
| 
      
 123 
     | 
    
         
            +
                    end
         
     | 
| 
      
 124 
     | 
    
         
            +
                  end
         
     | 
| 
      
 125 
     | 
    
         
            +
                end
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                def test_bulk_insert_with_a_multi_statement_query_in_a_nested_transaction
         
     | 
| 
      
 128 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 129 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 130 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 131 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 132 
     | 
    
         
            +
                  }
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
                  assert_difference "TrafficLight.count" do
         
     | 
| 
      
 135 
     | 
    
         
            +
                    ActiveRecord::Base.transaction do
         
     | 
| 
      
 136 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 137 
     | 
    
         
            +
                      assert_equal 1, conn.open_transactions
         
     | 
| 
      
 138 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 139 
     | 
    
         
            +
                      assert_equal 1, conn.open_transactions
         
     | 
| 
      
 140 
     | 
    
         
            +
                    end
         
     | 
| 
      
 141 
     | 
    
         
            +
                  end
         
     | 
| 
      
 142 
     | 
    
         
            +
                end
         
     | 
| 
      
 143 
     | 
    
         
            +
              end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              if current_adapter?(:Mysql2Adapter)
         
     | 
| 
      
 146 
     | 
    
         
            +
                def test_bulk_insert_with_multi_statements_enabled
         
     | 
| 
      
 147 
     | 
    
         
            +
                  run_without_connection do |orig_connection|
         
     | 
| 
      
 148 
     | 
    
         
            +
                    ActiveRecord::Base.establish_connection(
         
     | 
| 
      
 149 
     | 
    
         
            +
                      orig_connection.merge(flags: %w[MULTI_STATEMENTS])
         
     | 
| 
      
 150 
     | 
    
         
            +
                    )
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                    fixtures = {
         
     | 
| 
      
 153 
     | 
    
         
            +
                      "traffic_lights" => [
         
     | 
| 
      
 154 
     | 
    
         
            +
                        { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 155 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 156 
     | 
    
         
            +
                    }
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 159 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 160 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 161 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 162 
     | 
    
         
            +
                    end
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 165 
     | 
    
         
            +
                      ActiveRecord::Base.transaction do
         
     | 
| 
      
 166 
     | 
    
         
            +
                        conn = ActiveRecord::Base.connection
         
     | 
| 
      
 167 
     | 
    
         
            +
                        assert_equal 1, conn.open_transactions
         
     | 
| 
      
 168 
     | 
    
         
            +
                        conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 169 
     | 
    
         
            +
                        assert_equal 1, conn.open_transactions
         
     | 
| 
      
 170 
     | 
    
         
            +
                      end
         
     | 
| 
      
 171 
     | 
    
         
            +
                    end
         
     | 
| 
      
 172 
     | 
    
         
            +
             
     | 
| 
      
 173 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 174 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 175 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 176 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 177 
     | 
    
         
            +
                    end
         
     | 
| 
      
 178 
     | 
    
         
            +
                  end
         
     | 
| 
      
 179 
     | 
    
         
            +
                end
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
      
 181 
     | 
    
         
            +
                def test_bulk_insert_with_multi_statements_disabled
         
     | 
| 
      
 182 
     | 
    
         
            +
                  run_without_connection do |orig_connection|
         
     | 
| 
      
 183 
     | 
    
         
            +
                    ActiveRecord::Base.establish_connection(
         
     | 
| 
      
 184 
     | 
    
         
            +
                      orig_connection.merge(flags: [])
         
     | 
| 
      
 185 
     | 
    
         
            +
                    )
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
                    fixtures = {
         
     | 
| 
      
 188 
     | 
    
         
            +
                      "traffic_lights" => [
         
     | 
| 
      
 189 
     | 
    
         
            +
                        { "location" => "US", "state" => ["NY"], "long_state" => ["a"] },
         
     | 
| 
      
 190 
     | 
    
         
            +
                      ]
         
     | 
| 
      
 191 
     | 
    
         
            +
                    }
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
                    assert_raises(ActiveRecord::StatementInvalid) do
         
     | 
| 
      
 194 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 195 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 196 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 197 
     | 
    
         
            +
                    end
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 200 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 201 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 202 
     | 
    
         
            +
                    end
         
     | 
| 
      
 203 
     | 
    
         
            +
             
     | 
| 
      
 204 
     | 
    
         
            +
                    assert_raises(ActiveRecord::StatementInvalid) do
         
     | 
| 
      
 205 
     | 
    
         
            +
                      conn = ActiveRecord::Base.connection
         
     | 
| 
      
 206 
     | 
    
         
            +
                      conn.execute("SELECT 1; SELECT 2;")
         
     | 
| 
      
 207 
     | 
    
         
            +
                      conn.raw_connection.abandon_results!
         
     | 
| 
      
 208 
     | 
    
         
            +
                    end
         
     | 
| 
      
 209 
     | 
    
         
            +
                  end
         
     | 
| 
      
 210 
     | 
    
         
            +
                end
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
      
 212 
     | 
    
         
            +
                def test_insert_fixtures_set_raises_an_error_when_max_allowed_packet_is_smaller_than_fixtures_set_size
         
     | 
| 
      
 213 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 214 
     | 
    
         
            +
                  mysql_margin = 2
         
     | 
| 
      
 215 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 216 
     | 
    
         
            +
                  bytes_needed_to_have_a_1024_bytes_fixture = 906
         
     | 
| 
      
 217 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 218 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 219 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * bytes_needed_to_have_a_1024_bytes_fixture] },
         
     | 
| 
      
 220 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 221 
     | 
    
         
            +
                  }
         
     | 
| 
      
 222 
     | 
    
         
            +
             
     | 
| 
      
 223 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size - mysql_margin) do
         
     | 
| 
      
 224 
     | 
    
         
            +
                    error = assert_raises(ActiveRecord::ActiveRecordError) { conn.insert_fixtures_set(fixtures) }
         
     | 
| 
      
 225 
     | 
    
         
            +
                    assert_match(/Fixtures set is too large #{packet_size}\./, error.message)
         
     | 
| 
      
 226 
     | 
    
         
            +
                  end
         
     | 
| 
      
 227 
     | 
    
         
            +
                end
         
     | 
| 
      
 228 
     | 
    
         
            +
             
     | 
| 
      
 229 
     | 
    
         
            +
                def test_insert_fixture_set_when_max_allowed_packet_is_bigger_than_fixtures_set_size
         
     | 
| 
      
 230 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 231 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 232 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 233 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 234 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 51] },
         
     | 
| 
      
 235 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 236 
     | 
    
         
            +
                  }
         
     | 
| 
      
 237 
     | 
    
         
            +
             
     | 
| 
      
 238 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 239 
     | 
    
         
            +
                    assert_difference "TrafficLight.count" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 241 
     | 
    
         
            +
                    end
         
     | 
| 
      
 242 
     | 
    
         
            +
                  end
         
     | 
| 
      
 243 
     | 
    
         
            +
                end
         
     | 
| 
      
 244 
     | 
    
         
            +
             
     | 
| 
      
 245 
     | 
    
         
            +
                def test_insert_fixtures_set_split_the_total_sql_into_two_chunks_smaller_than_max_allowed_packet
         
     | 
| 
      
 246 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 247 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 248 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 249 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 250 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 251 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 252 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 450] },
         
     | 
| 
      
 253 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 254 
     | 
    
         
            +
                    "comments" => [
         
     | 
| 
      
 255 
     | 
    
         
            +
                      { "post_id" => 1, "body" => "a" * 450 },
         
     | 
| 
      
 256 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 257 
     | 
    
         
            +
                  }
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 260 
     | 
    
         
            +
                    conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
                    assert_equal 2, subscriber.events.size
         
     | 
| 
      
 263 
     | 
    
         
            +
                    assert_operator subscriber.events.first.bytesize, :<, packet_size
         
     | 
| 
      
 264 
     | 
    
         
            +
                    assert_operator subscriber.events.second.bytesize, :<, packet_size
         
     | 
| 
      
 265 
     | 
    
         
            +
                  end
         
     | 
| 
      
 266 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 267 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 268 
     | 
    
         
            +
                end
         
     | 
| 
      
 269 
     | 
    
         
            +
             
     | 
| 
      
 270 
     | 
    
         
            +
                def test_insert_fixtures_set_concat_total_sql_into_a_single_packet_smaller_than_max_allowed_packet
         
     | 
| 
      
 271 
     | 
    
         
            +
                  subscriber = InsertQuerySubscriber.new
         
     | 
| 
      
 272 
     | 
    
         
            +
                  subscription = ActiveSupport::Notifications.subscribe("sql.active_record", subscriber)
         
     | 
| 
      
 273 
     | 
    
         
            +
                  conn = ActiveRecord::Base.connection
         
     | 
| 
      
 274 
     | 
    
         
            +
                  packet_size = 1024
         
     | 
| 
      
 275 
     | 
    
         
            +
                  fixtures = {
         
     | 
| 
      
 276 
     | 
    
         
            +
                    "traffic_lights" => [
         
     | 
| 
      
 277 
     | 
    
         
            +
                      { "location" => "US", "state" => ["NY"], "long_state" => ["a" * 200] },
         
     | 
| 
      
 278 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 279 
     | 
    
         
            +
                    "comments" => [
         
     | 
| 
      
 280 
     | 
    
         
            +
                      { "post_id" => 1, "body" => "a" * 200 },
         
     | 
| 
      
 281 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 282 
     | 
    
         
            +
                  }
         
     | 
| 
      
 283 
     | 
    
         
            +
             
     | 
| 
      
 284 
     | 
    
         
            +
                  conn.stub(:max_allowed_packet, packet_size) do
         
     | 
| 
      
 285 
     | 
    
         
            +
                    assert_difference ["TrafficLight.count", "Comment.count"], +1 do
         
     | 
| 
      
 286 
     | 
    
         
            +
                      conn.insert_fixtures_set(fixtures)
         
     | 
| 
      
 287 
     | 
    
         
            +
                    end
         
     | 
| 
      
 288 
     | 
    
         
            +
                  end
         
     | 
| 
      
 289 
     | 
    
         
            +
                  assert_equal 1, subscriber.events.size
         
     | 
| 
      
 290 
     | 
    
         
            +
                ensure
         
     | 
| 
      
 291 
     | 
    
         
            +
                  ActiveSupport::Notifications.unsubscribe(subscription)
         
     | 
| 
      
 292 
     | 
    
         
            +
                end
         
     | 
| 
      
 293 
     | 
    
         
            +
              end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
              def test_auto_value_on_primary_key
         
     | 
| 
      
 296 
     | 
    
         
            +
                fixtures = [
         
     | 
| 
      
 297 
     | 
    
         
            +
                  { "name" => "first", "wheels_count" => 2 },
         
     | 
| 
      
 298 
     | 
    
         
            +
                  { "name" => "second", "wheels_count" => 3 }
         
     | 
| 
      
 299 
     | 
    
         
            +
                ]
         
     | 
| 
      
 300 
     | 
    
         
            +
                conn = ActiveRecord::Base.connection
         
     | 
| 
      
 301 
     | 
    
         
            +
                assert_nothing_raised do
         
     | 
| 
      
 302 
     | 
    
         
            +
                  conn.insert_fixtures_set({ "aircraft" => fixtures }, ["aircraft"])
         
     | 
| 
      
 303 
     | 
    
         
            +
                end
         
     | 
| 
      
 304 
     | 
    
         
            +
                result = conn.select_all("SELECT name, wheels_count FROM aircraft ORDER BY id")
         
     | 
| 
      
 305 
     | 
    
         
            +
                assert_equal fixtures, result.to_a
         
     | 
| 
      
 306 
     | 
    
         
            +
              end
         
     | 
| 
      
 307 
     | 
    
         
            +
             
     | 
| 
       57 
308 
     | 
    
         
             
              def test_broken_yaml_exception
         
     | 
| 
       58 
     | 
    
         
            -
                badyaml = Tempfile.new [ 
     | 
| 
       59 
     | 
    
         
            -
                badyaml.write  
     | 
| 
      
 309 
     | 
    
         
            +
                badyaml = Tempfile.new ["foo", ".yml"]
         
     | 
| 
      
 310 
     | 
    
         
            +
                badyaml.write "a: : "
         
     | 
| 
       60 
311 
     | 
    
         
             
                badyaml.flush
         
     | 
| 
       61 
312 
     | 
    
         | 
| 
       62 
313 
     | 
    
         
             
                dir  = File.dirname badyaml.path
         
     | 
| 
       63 
     | 
    
         
            -
                name = File.basename badyaml.path,  
     | 
| 
      
 314 
     | 
    
         
            +
                name = File.basename badyaml.path, ".yml"
         
     | 
| 
       64 
315 
     | 
    
         
             
                assert_raises(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
       65 
316 
     | 
    
         
             
                  ActiveRecord::FixtureSet.create_fixtures(dir, name)
         
     | 
| 
       66 
317 
     | 
    
         
             
                end
         
     | 
| 
         @@ -71,8 +322,8 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       71 
322 
     | 
    
         | 
| 
       72 
323 
     | 
    
         
             
              def test_create_fixtures
         
     | 
| 
       73 
324 
     | 
    
         
             
                fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, "parrots")
         
     | 
| 
       74 
     | 
    
         
            -
                assert Parrot.find_by_name( 
     | 
| 
       75 
     | 
    
         
            -
                assert fixtures.detect { |f| f.name ==  
     | 
| 
      
 325 
     | 
    
         
            +
                assert Parrot.find_by_name("Curious George"), "George is not in the database"
         
     | 
| 
      
 326 
     | 
    
         
            +
                assert fixtures.detect { |f| f.name == "parrots" }, "no fixtures named 'parrots' in #{fixtures.map(&:name).inspect}"
         
     | 
| 
       76 
327 
     | 
    
         
             
              end
         
     | 
| 
       77 
328 
     | 
    
         | 
| 
       78 
329 
     | 
    
         
             
              def test_multiple_clean_fixtures
         
     | 
| 
         @@ -83,10 +334,10 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       83 
334 
     | 
    
         
             
              end
         
     | 
| 
       84 
335 
     | 
    
         | 
| 
       85 
336 
     | 
    
         
             
              def test_create_symbol_fixtures
         
     | 
| 
       86 
     | 
    
         
            -
                fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, :collections, : 
     | 
| 
      
 337 
     | 
    
         
            +
                fixtures = ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT, :collections, collections: Course) { Course.connection }
         
     | 
| 
       87 
338 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
                assert Course.find_by_name( 
     | 
| 
       89 
     | 
    
         
            -
                assert fixtures.detect { |f| f.name ==  
     | 
| 
      
 339 
     | 
    
         
            +
                assert Course.find_by_name("Collection"), "course is not in the database"
         
     | 
| 
      
 340 
     | 
    
         
            +
                assert fixtures.detect { |f| f.name == "collections" }, "no fixtures named 'collections' in #{fixtures.map(&:name).inspect}"
         
     | 
| 
       90 
341 
     | 
    
         
             
              end
         
     | 
| 
       91 
342 
     | 
    
         | 
| 
       92 
343 
     | 
    
         
             
              def test_attributes
         
     | 
| 
         @@ -95,6 +346,24 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       95 
346 
     | 
    
         
             
                assert_nil(topics["second"]["author_email_address"])
         
     | 
| 
       96 
347 
     | 
    
         
             
              end
         
     | 
| 
       97 
348 
     | 
    
         | 
| 
      
 349 
     | 
    
         
            +
              def test_no_args_returns_all
         
     | 
| 
      
 350 
     | 
    
         
            +
                all_topics = topics
         
     | 
| 
      
 351 
     | 
    
         
            +
                assert_equal 5, all_topics.length
         
     | 
| 
      
 352 
     | 
    
         
            +
                assert_equal "The First Topic", all_topics.first["title"]
         
     | 
| 
      
 353 
     | 
    
         
            +
                assert_equal 5, all_topics.last.id
         
     | 
| 
      
 354 
     | 
    
         
            +
              end
         
     | 
| 
      
 355 
     | 
    
         
            +
             
     | 
| 
      
 356 
     | 
    
         
            +
              def test_no_args_record_returns_all_without_array
         
     | 
| 
      
 357 
     | 
    
         
            +
                all_binaries = binaries
         
     | 
| 
      
 358 
     | 
    
         
            +
                assert_kind_of(Array, all_binaries)
         
     | 
| 
      
 359 
     | 
    
         
            +
                assert_equal 2, binaries.length
         
     | 
| 
      
 360 
     | 
    
         
            +
              end
         
     | 
| 
      
 361 
     | 
    
         
            +
             
     | 
| 
      
 362 
     | 
    
         
            +
              def test_nil_raises
         
     | 
| 
      
 363 
     | 
    
         
            +
                assert_raise(StandardError) { topics(nil) }
         
     | 
| 
      
 364 
     | 
    
         
            +
                assert_raise(StandardError) { topics([nil]) }
         
     | 
| 
      
 365 
     | 
    
         
            +
              end
         
     | 
| 
      
 366 
     | 
    
         
            +
             
     | 
| 
       98 
367 
     | 
    
         
             
              def test_inserts
         
     | 
| 
       99 
368 
     | 
    
         
             
                create_fixtures("topics")
         
     | 
| 
       100 
369 
     | 
    
         
             
                first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM topics WHERE author_name = 'David'")
         
     | 
| 
         @@ -104,64 +373,62 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       104 
373 
     | 
    
         
             
                assert_nil(second_row["author_email_address"])
         
     | 
| 
       105 
374 
     | 
    
         
             
              end
         
     | 
| 
       106 
375 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
               
     | 
| 
       108 
     | 
    
         
            -
                 
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
                  ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                  ActiveRecord::Base.connection.create_table :prefix_other_topics_suffix do |t|
         
     | 
| 
       113 
     | 
    
         
            -
                    t.column :title, :string
         
     | 
| 
       114 
     | 
    
         
            -
                    t.column :author_name, :string
         
     | 
| 
       115 
     | 
    
         
            -
                    t.column :author_email_address, :string
         
     | 
| 
       116 
     | 
    
         
            -
                    t.column :written_on, :datetime
         
     | 
| 
       117 
     | 
    
         
            -
                    t.column :bonus_time, :time
         
     | 
| 
       118 
     | 
    
         
            -
                    t.column :last_read, :date
         
     | 
| 
       119 
     | 
    
         
            -
                    t.column :content, :string
         
     | 
| 
       120 
     | 
    
         
            -
                    t.column :approved, :boolean, :default => true
         
     | 
| 
       121 
     | 
    
         
            -
                    t.column :replies_count, :integer, :default => 0
         
     | 
| 
       122 
     | 
    
         
            -
                    t.column :parent_id, :integer
         
     | 
| 
       123 
     | 
    
         
            -
                    t.column :type, :string, :limit => 50
         
     | 
| 
       124 
     | 
    
         
            -
                  end
         
     | 
| 
      
 376 
     | 
    
         
            +
              def test_inserts_with_pre_and_suffix
         
     | 
| 
      
 377 
     | 
    
         
            +
                # Reset cache to make finds on the new table work
         
     | 
| 
      
 378 
     | 
    
         
            +
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
       125 
379 
     | 
    
         | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
                   
     | 
| 
       128 
     | 
    
         
            -
                   
     | 
| 
      
 380 
     | 
    
         
            +
                ActiveRecord::Base.connection.create_table :prefix_other_topics_suffix do |t|
         
     | 
| 
      
 381 
     | 
    
         
            +
                  t.column :title, :string
         
     | 
| 
      
 382 
     | 
    
         
            +
                  t.column :author_name, :string
         
     | 
| 
      
 383 
     | 
    
         
            +
                  t.column :author_email_address, :string
         
     | 
| 
      
 384 
     | 
    
         
            +
                  t.column :written_on, :datetime
         
     | 
| 
      
 385 
     | 
    
         
            +
                  t.column :bonus_time, :time
         
     | 
| 
      
 386 
     | 
    
         
            +
                  t.column :last_read, :date
         
     | 
| 
      
 387 
     | 
    
         
            +
                  t.column :content, :string
         
     | 
| 
      
 388 
     | 
    
         
            +
                  t.column :approved, :boolean, default: true
         
     | 
| 
      
 389 
     | 
    
         
            +
                  t.column :replies_count, :integer, default: 0
         
     | 
| 
      
 390 
     | 
    
         
            +
                  t.column :parent_id, :integer
         
     | 
| 
      
 391 
     | 
    
         
            +
                  t.column :type, :string, limit: 50
         
     | 
| 
      
 392 
     | 
    
         
            +
                end
         
     | 
| 
       129 
393 
     | 
    
         | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
      
 394 
     | 
    
         
            +
                # Store existing prefix/suffix
         
     | 
| 
      
 395 
     | 
    
         
            +
                old_prefix = ActiveRecord::Base.table_name_prefix
         
     | 
| 
      
 396 
     | 
    
         
            +
                old_suffix = ActiveRecord::Base.table_name_suffix
         
     | 
| 
       133 
397 
     | 
    
         | 
| 
       134 
     | 
    
         
            -
             
     | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
       137 
     | 
    
         
            -
             
     | 
| 
      
 398 
     | 
    
         
            +
                # Set a prefix/suffix we can test against
         
     | 
| 
      
 399 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = "prefix_"
         
     | 
| 
      
 400 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = "_suffix"
         
     | 
| 
      
 401 
     | 
    
         
            +
             
     | 
| 
      
 402 
     | 
    
         
            +
                other_topic_klass = Class.new(ActiveRecord::Base) do
         
     | 
| 
      
 403 
     | 
    
         
            +
                  def self.name
         
     | 
| 
      
 404 
     | 
    
         
            +
                    "OtherTopic"
         
     | 
| 
       138 
405 
     | 
    
         
             
                  end
         
     | 
| 
      
 406 
     | 
    
         
            +
                end
         
     | 
| 
       139 
407 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
      
 408 
     | 
    
         
            +
                topics = [create_fixtures("other_topics")].flatten.first
         
     | 
| 
       141 
409 
     | 
    
         | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
      
 410 
     | 
    
         
            +
                # This checks for a caching problem which causes a bug in the fixtures
         
     | 
| 
      
 411 
     | 
    
         
            +
                # class-level configuration helper.
         
     | 
| 
      
 412 
     | 
    
         
            +
                assert_not_nil topics, "Fixture data inserted, but fixture objects not returned from create"
         
     | 
| 
       145 
413 
     | 
    
         | 
| 
       146 
     | 
    
         
            -
             
     | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
      
 414 
     | 
    
         
            +
                first_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'David'")
         
     | 
| 
      
 415 
     | 
    
         
            +
                assert_not_nil first_row, "The prefix_other_topics_suffix table appears to be empty despite create_fixtures: the row with author_name = 'David' was not found"
         
     | 
| 
      
 416 
     | 
    
         
            +
                assert_equal("The First Topic", first_row["title"])
         
     | 
| 
       149 
417 
     | 
    
         | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
      
 418 
     | 
    
         
            +
                second_row = ActiveRecord::Base.connection.select_one("SELECT * FROM prefix_other_topics_suffix WHERE author_name = 'Mary'")
         
     | 
| 
      
 419 
     | 
    
         
            +
                assert_nil(second_row["author_email_address"])
         
     | 
| 
       152 
420 
     | 
    
         | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
       154 
     | 
    
         
            -
             
     | 
| 
       155 
     | 
    
         
            -
             
     | 
| 
       156 
     | 
    
         
            -
             
     | 
| 
      
 421 
     | 
    
         
            +
                assert_equal :prefix_other_topics_suffix, topics.table_name.to_sym
         
     | 
| 
      
 422 
     | 
    
         
            +
                # This assertion should preferably be the last in the list, because calling
         
     | 
| 
      
 423 
     | 
    
         
            +
                # other_topic_klass.table_name sets a class-level instance variable
         
     | 
| 
      
 424 
     | 
    
         
            +
                assert_equal :prefix_other_topics_suffix, other_topic_klass.table_name.to_sym
         
     | 
| 
       157 
425 
     | 
    
         | 
| 
       158 
     | 
    
         
            -
             
     | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
       160 
     | 
    
         
            -
             
     | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
      
 426 
     | 
    
         
            +
              ensure
         
     | 
| 
      
 427 
     | 
    
         
            +
                # Restore prefix/suffix to its previous values
         
     | 
| 
      
 428 
     | 
    
         
            +
                ActiveRecord::Base.table_name_prefix = old_prefix
         
     | 
| 
      
 429 
     | 
    
         
            +
                ActiveRecord::Base.table_name_suffix = old_suffix
         
     | 
| 
       162 
430 
     | 
    
         | 
| 
       163 
     | 
    
         
            -
             
     | 
| 
       164 
     | 
    
         
            -
                end
         
     | 
| 
      
 431 
     | 
    
         
            +
                ActiveRecord::Base.connection.drop_table :prefix_other_topics_suffix rescue nil
         
     | 
| 
       165 
432 
     | 
    
         
             
              end
         
     | 
| 
       166 
433 
     | 
    
         | 
| 
       167 
434 
     | 
    
         
             
              def test_insert_with_datetime
         
     | 
| 
         @@ -172,7 +439,7 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       172 
439 
     | 
    
         | 
| 
       173 
440 
     | 
    
         
             
              def test_logger_level_invariant
         
     | 
| 
       174 
441 
     | 
    
         
             
                level = ActiveRecord::Base.logger.level
         
     | 
| 
       175 
     | 
    
         
            -
                create_fixtures( 
     | 
| 
      
 442 
     | 
    
         
            +
                create_fixtures("topics")
         
     | 
| 
       176 
443 
     | 
    
         
             
                assert_equal level, ActiveRecord::Base.logger.level
         
     | 
| 
       177 
444 
     | 
    
         
             
              end
         
     | 
| 
       178 
445 
     | 
    
         | 
| 
         @@ -194,35 +461,46 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       194 
461 
     | 
    
         
             
              end
         
     | 
| 
       195 
462 
     | 
    
         | 
| 
       196 
463 
     | 
    
         
             
              def test_empty_yaml_fixture
         
     | 
| 
       197 
     | 
    
         
            -
                assert_not_nil ActiveRecord::FixtureSet.new( 
     | 
| 
      
 464 
     | 
    
         
            +
                assert_not_nil ActiveRecord::FixtureSet.new(nil, "accounts", Account, FIXTURES_ROOT + "/naked/yml/accounts")
         
     | 
| 
       198 
465 
     | 
    
         
             
              end
         
     | 
| 
       199 
466 
     | 
    
         | 
| 
       200 
467 
     | 
    
         
             
              def test_empty_yaml_fixture_with_a_comment_in_it
         
     | 
| 
       201 
     | 
    
         
            -
                assert_not_nil ActiveRecord::FixtureSet.new( 
     | 
| 
      
 468 
     | 
    
         
            +
                assert_not_nil ActiveRecord::FixtureSet.new(nil, "companies", Company, FIXTURES_ROOT + "/naked/yml/companies")
         
     | 
| 
       202 
469 
     | 
    
         
             
              end
         
     | 
| 
       203 
470 
     | 
    
         | 
| 
       204 
471 
     | 
    
         
             
              def test_nonexistent_fixture_file
         
     | 
| 
       205 
472 
     | 
    
         
             
                nonexistent_fixture_path = FIXTURES_ROOT + "/imnothere"
         
     | 
| 
       206 
473 
     | 
    
         | 
| 
       207 
     | 
    
         
            -
                #sanity check to make sure that this file never exists
         
     | 
| 
       208 
     | 
    
         
            -
                 
     | 
| 
      
 474 
     | 
    
         
            +
                # sanity check to make sure that this file never exists
         
     | 
| 
      
 475 
     | 
    
         
            +
                assert_empty Dir[nonexistent_fixture_path + "*"]
         
     | 
| 
       209 
476 
     | 
    
         | 
| 
       210 
477 
     | 
    
         
             
                assert_raise(Errno::ENOENT) do
         
     | 
| 
       211 
     | 
    
         
            -
                  ActiveRecord::FixtureSet.new( 
     | 
| 
      
 478 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "companies", Company, nonexistent_fixture_path)
         
     | 
| 
       212 
479 
     | 
    
         
             
                end
         
     | 
| 
       213 
480 
     | 
    
         
             
              end
         
     | 
| 
       214 
481 
     | 
    
         | 
| 
       215 
482 
     | 
    
         
             
              def test_dirty_dirty_yaml_file
         
     | 
| 
       216 
     | 
    
         
            -
                 
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
      
 483 
     | 
    
         
            +
                fixture_path = FIXTURES_ROOT + "/naked/yml/courses"
         
     | 
| 
      
 484 
     | 
    
         
            +
                error = assert_raise(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
      
 485 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "courses", Course, fixture_path)
         
     | 
| 
       218 
486 
     | 
    
         
             
                end
         
     | 
| 
      
 487 
     | 
    
         
            +
                assert_equal "fixture is not a hash: #{fixture_path}.yml", error.to_s
         
     | 
| 
      
 488 
     | 
    
         
            +
              end
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
              def test_yaml_file_with_one_invalid_fixture
         
     | 
| 
      
 491 
     | 
    
         
            +
                fixture_path = FIXTURES_ROOT + "/naked/yml/courses_with_invalid_key"
         
     | 
| 
      
 492 
     | 
    
         
            +
                error = assert_raise(ActiveRecord::Fixture::FormatError) do
         
     | 
| 
      
 493 
     | 
    
         
            +
                  ActiveRecord::FixtureSet.new(nil, "courses", Course, fixture_path)
         
     | 
| 
      
 494 
     | 
    
         
            +
                end
         
     | 
| 
      
 495 
     | 
    
         
            +
                assert_equal "fixture key is not a hash: #{fixture_path}.yml, keys: [\"two\"]", error.to_s
         
     | 
| 
       219 
496 
     | 
    
         
             
              end
         
     | 
| 
       220 
497 
     | 
    
         | 
| 
       221 
498 
     | 
    
         
             
              def test_yaml_file_with_invalid_column
         
     | 
| 
       222 
499 
     | 
    
         
             
                e = assert_raise(ActiveRecord::Fixture::FixtureError) do
         
     | 
| 
       223 
500 
     | 
    
         
             
                  ActiveRecord::FixtureSet.create_fixtures(FIXTURES_ROOT + "/naked/yml", "parrots")
         
     | 
| 
       224 
501 
     | 
    
         
             
                end
         
     | 
| 
       225 
     | 
    
         
            -
             
     | 
| 
      
 502 
     | 
    
         
            +
             
     | 
| 
      
 503 
     | 
    
         
            +
                assert_equal(%(table "parrots" has no columns named "arrr", "foobar".), e.message)
         
     | 
| 
       226 
504 
     | 
    
         
             
              end
         
     | 
| 
       227 
505 
     | 
    
         | 
| 
       228 
506 
     | 
    
         
             
              def test_yaml_file_with_symbol_columns
         
     | 
| 
         @@ -231,11 +509,11 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       231 
509 
     | 
    
         | 
| 
       232 
510 
     | 
    
         
             
              def test_omap_fixtures
         
     | 
| 
       233 
511 
     | 
    
         
             
                assert_nothing_raised do
         
     | 
| 
       234 
     | 
    
         
            -
                  fixtures = ActiveRecord::FixtureSet.new( 
     | 
| 
      
 512 
     | 
    
         
            +
                  fixtures = ActiveRecord::FixtureSet.new(nil, "categories", Category, FIXTURES_ROOT + "/categories_ordered")
         
     | 
| 
       235 
513 
     | 
    
         | 
| 
       236 
514 
     | 
    
         
             
                  fixtures.each.with_index do |(name, fixture), i|
         
     | 
| 
       237 
515 
     | 
    
         
             
                    assert_equal "fixture_no_#{i}", name
         
     | 
| 
       238 
     | 
    
         
            -
                    assert_equal "Category #{i}", fixture[ 
     | 
| 
      
 516 
     | 
    
         
            +
                    assert_equal "Category #{i}", fixture["name"]
         
     | 
| 
       239 
517 
     | 
    
         
             
                  end
         
     | 
| 
       240 
518 
     | 
    
         
             
                end
         
     | 
| 
       241 
519 
     | 
    
         
             
              end
         
     | 
| 
         @@ -251,10 +529,11 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       251 
529 
     | 
    
         
             
              end
         
     | 
| 
       252 
530 
     | 
    
         | 
| 
       253 
531 
     | 
    
         
             
              def test_binary_in_fixtures
         
     | 
| 
       254 
     | 
    
         
            -
                data = File. 
     | 
| 
       255 
     | 
    
         
            -
                data.force_encoding( 
     | 
| 
      
 532 
     | 
    
         
            +
                data = File.binread(ASSETS_ROOT + "/flowers.jpg")
         
     | 
| 
      
 533 
     | 
    
         
            +
                data.force_encoding("ASCII-8BIT")
         
     | 
| 
       256 
534 
     | 
    
         
             
                data.freeze
         
     | 
| 
       257 
535 
     | 
    
         
             
                assert_equal data, @flowers.data
         
     | 
| 
      
 536 
     | 
    
         
            +
                assert_equal data, @binary_helper.data
         
     | 
| 
       258 
537 
     | 
    
         
             
              end
         
     | 
| 
       259 
538 
     | 
    
         | 
| 
       260 
539 
     | 
    
         
             
              def test_serialized_fixtures
         
     | 
| 
         @@ -262,8 +541,8 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       262 
541 
     | 
    
         
             
              end
         
     | 
| 
       263 
542 
     | 
    
         | 
| 
       264 
543 
     | 
    
         
             
              def test_fixtures_are_set_up_with_database_env_variable
         
     | 
| 
       265 
     | 
    
         
            -
                db_url_tmp = ENV[ 
     | 
| 
       266 
     | 
    
         
            -
                ENV[ 
     | 
| 
      
 544 
     | 
    
         
            +
                db_url_tmp = ENV["DATABASE_URL"]
         
     | 
| 
      
 545 
     | 
    
         
            +
                ENV["DATABASE_URL"] = "sqlite3::memory:"
         
     | 
| 
       267 
546 
     | 
    
         
             
                ActiveRecord::Base.stub(:configurations, {}) do
         
     | 
| 
       268 
547 
     | 
    
         
             
                  test_case = Class.new(ActiveRecord::TestCase) do
         
     | 
| 
       269 
548 
     | 
    
         
             
                    fixtures :accounts
         
     | 
| 
         @@ -278,11 +557,11 @@ class FixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       278 
557 
     | 
    
         
             
                  assert result.passed?, "Expected #{result.name} to pass:\n#{result}"
         
     | 
| 
       279 
558 
     | 
    
         
             
                end
         
     | 
| 
       280 
559 
     | 
    
         
             
              ensure
         
     | 
| 
       281 
     | 
    
         
            -
                ENV[ 
     | 
| 
      
 560 
     | 
    
         
            +
                ENV["DATABASE_URL"] = db_url_tmp
         
     | 
| 
       282 
561 
     | 
    
         
             
              end
         
     | 
| 
       283 
562 
     | 
    
         
             
            end
         
     | 
| 
       284 
563 
     | 
    
         | 
| 
       285 
     | 
    
         
            -
            class HasManyThroughFixture <  
     | 
| 
      
 564 
     | 
    
         
            +
            class HasManyThroughFixture < ActiveRecord::TestCase
         
     | 
| 
       286 
565 
     | 
    
         
             
              def make_model(name)
         
     | 
| 
       287 
566 
     | 
    
         
             
                Class.new(ActiveRecord::Base) { define_singleton_method(:name) { name } }
         
     | 
| 
       288 
567 
     | 
    
         
             
              end
         
     | 
| 
         @@ -293,17 +572,17 @@ class HasManyThroughFixture < ActiveSupport::TestCase 
     | 
|
| 
       293 
572 
     | 
    
         
             
                treasure = make_model "Treasure"
         
     | 
| 
       294 
573 
     | 
    
         | 
| 
       295 
574 
     | 
    
         
             
                pt.table_name = "parrots_treasures"
         
     | 
| 
       296 
     | 
    
         
            -
                pt.belongs_to :parrot, : 
     | 
| 
       297 
     | 
    
         
            -
                pt.belongs_to :treasure, : 
     | 
| 
      
 575 
     | 
    
         
            +
                pt.belongs_to :parrot, anonymous_class: parrot
         
     | 
| 
      
 576 
     | 
    
         
            +
                pt.belongs_to :treasure, anonymous_class: treasure
         
     | 
| 
       298 
577 
     | 
    
         | 
| 
       299 
     | 
    
         
            -
                parrot.has_many :parrot_treasures, : 
     | 
| 
       300 
     | 
    
         
            -
                parrot.has_many :treasures, : 
     | 
| 
      
 578 
     | 
    
         
            +
                parrot.has_many :parrot_treasures, anonymous_class: pt
         
     | 
| 
      
 579 
     | 
    
         
            +
                parrot.has_many :treasures, through: :parrot_treasures
         
     | 
| 
       301 
580 
     | 
    
         | 
| 
       302 
     | 
    
         
            -
                parrots = File.join FIXTURES_ROOT,  
     | 
| 
      
 581 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
       303 
582 
     | 
    
         | 
| 
       304 
     | 
    
         
            -
                fs = ActiveRecord::FixtureSet.new 
     | 
| 
      
 583 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
       305 
584 
     | 
    
         
             
                rows = fs.table_rows
         
     | 
| 
       306 
     | 
    
         
            -
                assert_equal load_has_and_belongs_to_many[ 
     | 
| 
      
 585 
     | 
    
         
            +
                assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrots_treasures"]
         
     | 
| 
       307 
586 
     | 
    
         
             
              end
         
     | 
| 
       308 
587 
     | 
    
         | 
| 
       309 
588 
     | 
    
         
             
              def test_has_many_through_with_renamed_table
         
     | 
| 
         @@ -311,26 +590,30 @@ class HasManyThroughFixture < ActiveSupport::TestCase 
     | 
|
| 
       311 
590 
     | 
    
         
             
                parrot = make_model "Parrot"
         
     | 
| 
       312 
591 
     | 
    
         
             
                treasure = make_model "Treasure"
         
     | 
| 
       313 
592 
     | 
    
         | 
| 
       314 
     | 
    
         
            -
                pt.belongs_to :parrot, : 
     | 
| 
       315 
     | 
    
         
            -
                pt.belongs_to :treasure, : 
     | 
| 
      
 593 
     | 
    
         
            +
                pt.belongs_to :parrot, anonymous_class: parrot
         
     | 
| 
      
 594 
     | 
    
         
            +
                pt.belongs_to :treasure, anonymous_class: treasure
         
     | 
| 
       316 
595 
     | 
    
         | 
| 
       317 
     | 
    
         
            -
                parrot.has_many :parrot_treasures, : 
     | 
| 
       318 
     | 
    
         
            -
                parrot.has_many :treasures, : 
     | 
| 
      
 596 
     | 
    
         
            +
                parrot.has_many :parrot_treasures, anonymous_class: pt
         
     | 
| 
      
 597 
     | 
    
         
            +
                parrot.has_many :treasures, through: :parrot_treasures
         
     | 
| 
       319 
598 
     | 
    
         | 
| 
       320 
     | 
    
         
            -
                parrots = File.join FIXTURES_ROOT,  
     | 
| 
      
 599 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
       321 
600 
     | 
    
         | 
| 
       322 
     | 
    
         
            -
                fs = ActiveRecord::FixtureSet.new 
     | 
| 
      
 601 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
       323 
602 
     | 
    
         
             
                rows = fs.table_rows
         
     | 
| 
       324 
     | 
    
         
            -
                assert_equal load_has_and_belongs_to_many[ 
     | 
| 
      
 603 
     | 
    
         
            +
                assert_equal load_has_and_belongs_to_many["parrots_treasures"], rows["parrot_treasures"]
         
     | 
| 
      
 604 
     | 
    
         
            +
              end
         
     | 
| 
      
 605 
     | 
    
         
            +
             
     | 
| 
      
 606 
     | 
    
         
            +
              def test_has_and_belongs_to_many_order
         
     | 
| 
      
 607 
     | 
    
         
            +
                assert_equal ["parrots", "parrots_treasures"], load_has_and_belongs_to_many.keys
         
     | 
| 
       325 
608 
     | 
    
         
             
              end
         
     | 
| 
       326 
609 
     | 
    
         | 
| 
       327 
610 
     | 
    
         
             
              def load_has_and_belongs_to_many
         
     | 
| 
       328 
611 
     | 
    
         
             
                parrot = make_model "Parrot"
         
     | 
| 
       329 
612 
     | 
    
         
             
                parrot.has_and_belongs_to_many :treasures
         
     | 
| 
       330 
613 
     | 
    
         | 
| 
       331 
     | 
    
         
            -
                parrots = File.join FIXTURES_ROOT,  
     | 
| 
      
 614 
     | 
    
         
            +
                parrots = File.join FIXTURES_ROOT, "parrots"
         
     | 
| 
       332 
615 
     | 
    
         | 
| 
       333 
     | 
    
         
            -
                fs = ActiveRecord::FixtureSet.new 
     | 
| 
      
 616 
     | 
    
         
            +
                fs = ActiveRecord::FixtureSet.new(nil, "parrots", parrot, parrots)
         
     | 
| 
       334 
617 
     | 
    
         
             
                fs.table_rows
         
     | 
| 
       335 
618 
     | 
    
         
             
              end
         
     | 
| 
       336 
619 
     | 
    
         
             
            end
         
     | 
| 
         @@ -339,9 +622,10 @@ if Account.connection.respond_to?(:reset_pk_sequence!) 
     | 
|
| 
       339 
622 
     | 
    
         
             
              class FixturesResetPkSequenceTest < ActiveRecord::TestCase
         
     | 
| 
       340 
623 
     | 
    
         
             
                fixtures :accounts
         
     | 
| 
       341 
624 
     | 
    
         
             
                fixtures :companies
         
     | 
| 
      
 625 
     | 
    
         
            +
                self.use_transactional_tests = false
         
     | 
| 
       342 
626 
     | 
    
         | 
| 
       343 
627 
     | 
    
         
             
                def setup
         
     | 
| 
       344 
     | 
    
         
            -
                  @instances = [Account.new(: 
     | 
| 
      
 628 
     | 
    
         
            +
                  @instances = [Account.new(credit_limit: 50), Company.new(name: "RoR Consulting"), Course.new(name: "Test")]
         
     | 
| 
       345 
629 
     | 
    
         
             
                  ActiveRecord::FixtureSet.reset_cache # make sure tables get reinitialized
         
     | 
| 
       346 
630 
     | 
    
         
             
                end
         
     | 
| 
       347 
631 
     | 
    
         | 
| 
         @@ -370,7 +654,7 @@ if Account.connection.respond_to?(:reset_pk_sequence!) 
     | 
|
| 
       370 
654 
     | 
    
         
             
                def test_create_fixtures_resets_sequences_when_not_cached
         
     | 
| 
       371 
655 
     | 
    
         
             
                  @instances.each do |instance|
         
     | 
| 
       372 
656 
     | 
    
         
             
                    max_id = create_fixtures(instance.class.table_name).first.fixtures.inject(0) do |_max_id, (_, fixture)|
         
     | 
| 
       373 
     | 
    
         
            -
                      fixture_id = fixture[ 
     | 
| 
      
 657 
     | 
    
         
            +
                      fixture_id = fixture["id"].to_i
         
     | 
| 
       374 
658 
     | 
    
         
             
                      fixture_id > _max_id ? fixture_id : _max_id
         
     | 
| 
       375 
659 
     | 
    
         
             
                    end
         
     | 
| 
       376 
660 
     | 
    
         | 
| 
         @@ -387,14 +671,14 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase 
     | 
|
| 
       387 
671 
     | 
    
         
             
              fixtures :topics, :developers, :accounts
         
     | 
| 
       388 
672 
     | 
    
         | 
| 
       389 
673 
     | 
    
         
             
              def test_without_complete_instantiation
         
     | 
| 
       390 
     | 
    
         
            -
                 
     | 
| 
       391 
     | 
    
         
            -
                 
     | 
| 
       392 
     | 
    
         
            -
                 
     | 
| 
       393 
     | 
    
         
            -
                 
     | 
| 
      
 674 
     | 
    
         
            +
                assert_not defined?(@first)
         
     | 
| 
      
 675 
     | 
    
         
            +
                assert_not defined?(@topics)
         
     | 
| 
      
 676 
     | 
    
         
            +
                assert_not defined?(@developers)
         
     | 
| 
      
 677 
     | 
    
         
            +
                assert_not defined?(@accounts)
         
     | 
| 
       394 
678 
     | 
    
         
             
              end
         
     | 
| 
       395 
679 
     | 
    
         | 
| 
       396 
680 
     | 
    
         
             
              def test_fixtures_from_root_yml_without_instantiation
         
     | 
| 
       397 
     | 
    
         
            -
                 
     | 
| 
      
 681 
     | 
    
         
            +
                assert_not defined?(@unknown), "@unknown is not defined"
         
     | 
| 
       398 
682 
     | 
    
         
             
              end
         
     | 
| 
       399 
683 
     | 
    
         | 
| 
       400 
684 
     | 
    
         
             
              def test_visibility_of_accessor_method
         
     | 
| 
         @@ -416,7 +700,7 @@ class FixturesWithoutInstantiationTest < ActiveRecord::TestCase 
     | 
|
| 
       416 
700 
     | 
    
         
             
              def test_reloading_fixtures_through_accessor_methods
         
     | 
| 
       417 
701 
     | 
    
         
             
                topic = Struct.new(:title)
         
     | 
| 
       418 
702 
     | 
    
         
             
                assert_equal "The First Topic", topics(:first).title
         
     | 
| 
       419 
     | 
    
         
            -
                assert_called(@loaded_fixtures[ 
     | 
| 
      
 703 
     | 
    
         
            +
                assert_called(@loaded_fixtures["topics"]["first"], :find, returns: topic.new("Fresh Topic!")) do
         
     | 
| 
       420 
704 
     | 
    
         
             
                  assert_equal "Fresh Topic!", topics(:first, true).title
         
     | 
| 
       421 
705 
     | 
    
         
             
                end
         
     | 
| 
       422 
706 
     | 
    
         
             
              end
         
     | 
| 
         @@ -429,7 +713,7 @@ class FixturesWithoutInstanceInstantiationTest < ActiveRecord::TestCase 
     | 
|
| 
       429 
713 
     | 
    
         
             
              fixtures :topics, :developers, :accounts
         
     | 
| 
       430 
714 
     | 
    
         | 
| 
       431 
715 
     | 
    
         
             
              def test_without_instance_instantiation
         
     | 
| 
       432 
     | 
    
         
            -
                 
     | 
| 
      
 716 
     | 
    
         
            +
                assert_not defined?(@first), "@first is not defined"
         
     | 
| 
       433 
717 
     | 
    
         
             
              end
         
     | 
| 
       434 
718 
     | 
    
         
             
            end
         
     | 
| 
       435 
719 
     | 
    
         | 
| 
         @@ -511,13 +795,13 @@ class OverRideFixtureMethodTest < ActiveRecord::TestCase 
     | 
|
| 
       511 
795 
     | 
    
         | 
| 
       512 
796 
     | 
    
         
             
              def topics(name)
         
     | 
| 
       513 
797 
     | 
    
         
             
                topic = super
         
     | 
| 
       514 
     | 
    
         
            -
                topic.title =  
     | 
| 
      
 798 
     | 
    
         
            +
                topic.title = "omg"
         
     | 
| 
       515 
799 
     | 
    
         
             
                topic
         
     | 
| 
       516 
800 
     | 
    
         
             
              end
         
     | 
| 
       517 
801 
     | 
    
         | 
| 
       518 
802 
     | 
    
         
             
              def test_fixture_methods_can_be_overridden
         
     | 
| 
       519 
803 
     | 
    
         
             
                x = topics :first
         
     | 
| 
       520 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 804 
     | 
    
         
            +
                assert_equal "omg", x.title
         
     | 
| 
       521 
805 
     | 
    
         
             
              end
         
     | 
| 
       522 
806 
     | 
    
         
             
            end
         
     | 
| 
       523 
807 
     | 
    
         | 
| 
         @@ -525,7 +809,7 @@ class FixtureWithSetModelClassTest < ActiveRecord::TestCase 
     | 
|
| 
       525 
809 
     | 
    
         
             
              fixtures :other_posts, :other_comments
         
     | 
| 
       526 
810 
     | 
    
         | 
| 
       527 
811 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       528 
     | 
    
         
            -
              # and thus takes into account the  
     | 
| 
      
 812 
     | 
    
         
            +
              # and thus takes into account the `model_class` set in the fixture.
         
     | 
| 
       529 
813 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       530 
814 
     | 
    
         | 
| 
       531 
815 
     | 
    
         
             
              def test_uses_fixture_class_defined_in_yaml
         
     | 
| 
         @@ -545,7 +829,7 @@ class SetFixtureClassPrevailsTest < ActiveRecord::TestCase 
     | 
|
| 
       545 
829 
     | 
    
         
             
              fixtures :bad_posts
         
     | 
| 
       546 
830 
     | 
    
         | 
| 
       547 
831 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       548 
     | 
    
         
            -
              # and thus takes into account  
     | 
| 
      
 832 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
       549 
833 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       550 
834 
     | 
    
         | 
| 
       551 
835 
     | 
    
         
             
              def test_uses_set_fixture_class
         
     | 
| 
         @@ -554,10 +838,10 @@ class SetFixtureClassPrevailsTest < ActiveRecord::TestCase 
     | 
|
| 
       554 
838 
     | 
    
         
             
            end
         
     | 
| 
       555 
839 
     | 
    
         | 
| 
       556 
840 
     | 
    
         
             
            class CheckSetTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       557 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 841 
     | 
    
         
            +
              set_fixture_class funny_jokes: Joke
         
     | 
| 
       558 
842 
     | 
    
         
             
              fixtures :funny_jokes
         
     | 
| 
       559 
843 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       560 
     | 
    
         
            -
              # and thus takes into account our set_fixture_class
         
     | 
| 
      
 844 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
       561 
845 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       562 
846 
     | 
    
         | 
| 
       563 
847 
     | 
    
         
             
              def test_table_method
         
     | 
| 
         @@ -566,10 +850,10 @@ class CheckSetTableNameFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       566 
850 
     | 
    
         
             
            end
         
     | 
| 
       567 
851 
     | 
    
         | 
| 
       568 
852 
     | 
    
         
             
            class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       569 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 853 
     | 
    
         
            +
              set_fixture_class items: Book
         
     | 
| 
       570 
854 
     | 
    
         
             
              fixtures :items
         
     | 
| 
       571 
855 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       572 
     | 
    
         
            -
              # and thus takes into account our set_fixture_class
         
     | 
| 
      
 856 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
       573 
857 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       574 
858 
     | 
    
         | 
| 
       575 
859 
     | 
    
         
             
              def test_named_accessor
         
     | 
| 
         @@ -578,10 +862,10 @@ class FixtureNameIsNotTableNameFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       578 
862 
     | 
    
         
             
            end
         
     | 
| 
       579 
863 
     | 
    
         | 
| 
       580 
864 
     | 
    
         
             
            class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       581 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 865 
     | 
    
         
            +
              set_fixture_class items: Book, funny_jokes: Joke
         
     | 
| 
       582 
866 
     | 
    
         
             
              fixtures :items, :funny_jokes
         
     | 
| 
       583 
867 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       584 
     | 
    
         
            -
              # and thus takes into account our set_fixture_class
         
     | 
| 
      
 868 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
       585 
869 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       586 
870 
     | 
    
         | 
| 
       587 
871 
     | 
    
         
             
              def test_named_accessor_of_differently_named_fixture
         
     | 
| 
         @@ -594,7 +878,7 @@ class FixtureNameIsNotTableNameMultipleFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       594 
878 
     | 
    
         
             
            end
         
     | 
| 
       595 
879 
     | 
    
         | 
| 
       596 
880 
     | 
    
         
             
            class CustomConnectionFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       597 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 881 
     | 
    
         
            +
              set_fixture_class courses: Course
         
     | 
| 
       598 
882 
     | 
    
         
             
              fixtures :courses
         
     | 
| 
       599 
883 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       600 
884 
     | 
    
         | 
| 
         @@ -609,7 +893,7 @@ class CustomConnectionFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       609 
893 
     | 
    
         
             
            end
         
     | 
| 
       610 
894 
     | 
    
         | 
| 
       611 
895 
     | 
    
         
             
            class TransactionalFixturesOnCustomConnectionTest < ActiveRecord::TestCase
         
     | 
| 
       612 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 896 
     | 
    
         
            +
              set_fixture_class courses: Course
         
     | 
| 
       613 
897 
     | 
    
         
             
              fixtures :courses
         
     | 
| 
       614 
898 
     | 
    
         
             
              self.use_transactional_tests = true
         
     | 
| 
       615 
899 
     | 
    
         | 
| 
         @@ -623,6 +907,83 @@ class TransactionalFixturesOnCustomConnectionTest < ActiveRecord::TestCase 
     | 
|
| 
       623 
907 
     | 
    
         
             
              end
         
     | 
| 
       624 
908 
     | 
    
         
             
            end
         
     | 
| 
       625 
909 
     | 
    
         | 
| 
      
 910 
     | 
    
         
            +
            class TransactionalFixturesOnConnectionNotification < ActiveRecord::TestCase
         
     | 
| 
      
 911 
     | 
    
         
            +
              self.use_transactional_tests = true
         
     | 
| 
      
 912 
     | 
    
         
            +
              self.use_instantiated_fixtures = false
         
     | 
| 
      
 913 
     | 
    
         
            +
             
     | 
| 
      
 914 
     | 
    
         
            +
              def test_transaction_created_on_connection_notification
         
     | 
| 
      
 915 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 916 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 917 
     | 
    
         
            +
             
     | 
| 
      
 918 
     | 
    
         
            +
                  def transaction_open?; end
         
     | 
| 
      
 919 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 920 
     | 
    
         
            +
                  def rollback_transaction(*args); end
         
     | 
| 
      
 921 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 922 
     | 
    
         
            +
             
     | 
| 
      
 923 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 924 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 925 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 926 
     | 
    
         
            +
             
     | 
| 
      
 927 
     | 
    
         
            +
                assert_called_with(connection, :begin_transaction, [joinable: false, _lazy: false]) do
         
     | 
| 
      
 928 
     | 
    
         
            +
                  fire_connection_notification(connection)
         
     | 
| 
      
 929 
     | 
    
         
            +
                end
         
     | 
| 
      
 930 
     | 
    
         
            +
              end
         
     | 
| 
      
 931 
     | 
    
         
            +
             
     | 
| 
      
 932 
     | 
    
         
            +
              def test_notification_established_transactions_are_rolled_back
         
     | 
| 
      
 933 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 934 
     | 
    
         
            +
                  attr_accessor :rollback_transaction_called
         
     | 
| 
      
 935 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 936 
     | 
    
         
            +
             
     | 
| 
      
 937 
     | 
    
         
            +
                  def transaction_open?; true; end
         
     | 
| 
      
 938 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 939 
     | 
    
         
            +
                  def rollback_transaction(*args)
         
     | 
| 
      
 940 
     | 
    
         
            +
                    @rollback_transaction_called = true
         
     | 
| 
      
 941 
     | 
    
         
            +
                  end
         
     | 
| 
      
 942 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 943 
     | 
    
         
            +
             
     | 
| 
      
 944 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 945 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 946 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 947 
     | 
    
         
            +
             
     | 
| 
      
 948 
     | 
    
         
            +
                fire_connection_notification(connection)
         
     | 
| 
      
 949 
     | 
    
         
            +
                teardown_fixtures
         
     | 
| 
      
 950 
     | 
    
         
            +
             
     | 
| 
      
 951 
     | 
    
         
            +
                assert(connection.rollback_transaction_called, "Expected <mock connection>#rollback_transaction to be called but was not")
         
     | 
| 
      
 952 
     | 
    
         
            +
              end
         
     | 
| 
      
 953 
     | 
    
         
            +
             
     | 
| 
      
 954 
     | 
    
         
            +
              def test_transaction_created_on_connection_notification_for_shard
         
     | 
| 
      
 955 
     | 
    
         
            +
                connection = Class.new do
         
     | 
| 
      
 956 
     | 
    
         
            +
                  attr_accessor :pool
         
     | 
| 
      
 957 
     | 
    
         
            +
             
     | 
| 
      
 958 
     | 
    
         
            +
                  def transaction_open?; end
         
     | 
| 
      
 959 
     | 
    
         
            +
                  def begin_transaction(*args); end
         
     | 
| 
      
 960 
     | 
    
         
            +
                  def rollback_transaction(*args); end
         
     | 
| 
      
 961 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 962 
     | 
    
         
            +
             
     | 
| 
      
 963 
     | 
    
         
            +
                connection.pool = Class.new do
         
     | 
| 
      
 964 
     | 
    
         
            +
                  def lock_thread=(lock_thread); end
         
     | 
| 
      
 965 
     | 
    
         
            +
                end.new
         
     | 
| 
      
 966 
     | 
    
         
            +
             
     | 
| 
      
 967 
     | 
    
         
            +
                assert_called_with(connection, :begin_transaction, [joinable: false, _lazy: false]) do
         
     | 
| 
      
 968 
     | 
    
         
            +
                  fire_connection_notification(connection, shard: :shard_two)
         
     | 
| 
      
 969 
     | 
    
         
            +
                end
         
     | 
| 
      
 970 
     | 
    
         
            +
              end
         
     | 
| 
      
 971 
     | 
    
         
            +
             
     | 
| 
      
 972 
     | 
    
         
            +
              private
         
     | 
| 
      
 973 
     | 
    
         
            +
                def fire_connection_notification(connection, shard: ActiveRecord::Base.default_shard)
         
     | 
| 
      
 974 
     | 
    
         
            +
                  assert_called_with(ActiveRecord::Base.connection_handler, :retrieve_connection, ["book", { shard: shard }], returns: connection) do
         
     | 
| 
      
 975 
     | 
    
         
            +
                    message_bus = ActiveSupport::Notifications.instrumenter
         
     | 
| 
      
 976 
     | 
    
         
            +
                    payload = {
         
     | 
| 
      
 977 
     | 
    
         
            +
                      spec_name: "book",
         
     | 
| 
      
 978 
     | 
    
         
            +
                      shard: shard,
         
     | 
| 
      
 979 
     | 
    
         
            +
                      config: nil,
         
     | 
| 
      
 980 
     | 
    
         
            +
                    }
         
     | 
| 
      
 981 
     | 
    
         
            +
             
     | 
| 
      
 982 
     | 
    
         
            +
                    message_bus.instrument("!connection.active_record", payload) { }
         
     | 
| 
      
 983 
     | 
    
         
            +
                  end
         
     | 
| 
      
 984 
     | 
    
         
            +
                end
         
     | 
| 
      
 985 
     | 
    
         
            +
            end
         
     | 
| 
      
 986 
     | 
    
         
            +
             
     | 
| 
       626 
987 
     | 
    
         
             
            class InvalidTableNameFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       627 
988 
     | 
    
         
             
              fixtures :funny_jokes
         
     | 
| 
       628 
989 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
         @@ -637,10 +998,10 @@ class InvalidTableNameFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       637 
998 
     | 
    
         
             
            end
         
     | 
| 
       638 
999 
     | 
    
         | 
| 
       639 
1000 
     | 
    
         
             
            class CheckEscapedYamlFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       640 
     | 
    
         
            -
              set_fixture_class : 
     | 
| 
      
 1001 
     | 
    
         
            +
              set_fixture_class funny_jokes: Joke
         
     | 
| 
       641 
1002 
     | 
    
         
             
              fixtures :funny_jokes
         
     | 
| 
       642 
1003 
     | 
    
         
             
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
       643 
     | 
    
         
            -
              # and thus takes into account our set_fixture_class
         
     | 
| 
      
 1004 
     | 
    
         
            +
              # and thus takes into account our `set_fixture_class`.
         
     | 
| 
       644 
1005 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       645 
1006 
     | 
    
         | 
| 
       646 
1007 
     | 
    
         
             
              def test_proper_escaped_fixture
         
     | 
| 
         @@ -680,7 +1041,7 @@ class FixturesBrokenRollbackTest < ActiveRecord::TestCase 
     | 
|
| 
       680 
1041 
     | 
    
         | 
| 
       681 
1042 
     | 
    
         
             
              private
         
     | 
| 
       682 
1043 
     | 
    
         
             
                def load_fixtures(config)
         
     | 
| 
       683 
     | 
    
         
            -
                  raise  
     | 
| 
      
 1044 
     | 
    
         
            +
                  raise "argh"
         
     | 
| 
       684 
1045 
     | 
    
         
             
                end
         
     | 
| 
       685 
1046 
     | 
    
         
             
            end
         
     | 
| 
       686 
1047 
     | 
    
         | 
| 
         @@ -690,7 +1051,7 @@ class LoadAllFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       690 
1051 
     | 
    
         
             
                self.class.fixtures :all
         
     | 
| 
       691 
1052 
     | 
    
         | 
| 
       692 
1053 
     | 
    
         
             
                if File.symlink? FIXTURES_ROOT + "/all/admin"
         
     | 
| 
       693 
     | 
    
         
            -
                  assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
         
     | 
| 
      
 1054 
     | 
    
         
            +
                  assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
       694 
1055 
     | 
    
         
             
                end
         
     | 
| 
       695 
1056 
     | 
    
         
             
              ensure
         
     | 
| 
       696 
1057 
     | 
    
         
             
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
         @@ -699,11 +1060,11 @@ end 
     | 
|
| 
       699 
1060 
     | 
    
         | 
| 
       700 
1061 
     | 
    
         
             
            class LoadAllFixturesWithPathnameTest < ActiveRecord::TestCase
         
     | 
| 
       701 
1062 
     | 
    
         
             
              def test_all_there
         
     | 
| 
       702 
     | 
    
         
            -
                self.class.fixture_path = Pathname.new(FIXTURES_ROOT).join( 
     | 
| 
      
 1063 
     | 
    
         
            +
                self.class.fixture_path = Pathname.new(FIXTURES_ROOT).join("all")
         
     | 
| 
       703 
1064 
     | 
    
         
             
                self.class.fixtures :all
         
     | 
| 
       704 
1065 
     | 
    
         | 
| 
       705 
1066 
     | 
    
         
             
                if File.symlink? FIXTURES_ROOT + "/all/admin"
         
     | 
| 
       706 
     | 
    
         
            -
                  assert_equal %w(admin/accounts admin/users developers people tasks), fixture_table_names.sort
         
     | 
| 
      
 1067 
     | 
    
         
            +
                  assert_equal %w(admin/accounts admin/users developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
       707 
1068 
     | 
    
         
             
                end
         
     | 
| 
       708 
1069 
     | 
    
         
             
              ensure
         
     | 
| 
       709 
1070 
     | 
    
         
             
                ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
         @@ -712,7 +1073,7 @@ end 
     | 
|
| 
       712 
1073 
     | 
    
         | 
| 
       713 
1074 
     | 
    
         
             
            class FasterFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       714 
1075 
     | 
    
         
             
              self.use_transactional_tests = false
         
     | 
| 
       715 
     | 
    
         
            -
              fixtures :categories, :authors
         
     | 
| 
      
 1076 
     | 
    
         
            +
              fixtures :categories, :authors, :author_addresses
         
     | 
| 
       716 
1077 
     | 
    
         | 
| 
       717 
1078 
     | 
    
         
             
              def load_extra_fixture(name)
         
     | 
| 
       718 
1079 
     | 
    
         
             
                fixture = create_fixtures(name).first
         
     | 
| 
         @@ -721,28 +1082,30 @@ class FasterFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       721 
1082 
     | 
    
         
             
              end
         
     | 
| 
       722 
1083 
     | 
    
         | 
| 
       723 
1084 
     | 
    
         
             
              def test_cache
         
     | 
| 
       724 
     | 
    
         
            -
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection,  
     | 
| 
       725 
     | 
    
         
            -
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection,  
     | 
| 
      
 1085 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "categories")
         
     | 
| 
      
 1086 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "authors")
         
     | 
| 
       726 
1087 
     | 
    
         | 
| 
       727 
1088 
     | 
    
         
             
                assert_no_queries do
         
     | 
| 
       728 
     | 
    
         
            -
                  create_fixtures( 
     | 
| 
       729 
     | 
    
         
            -
                  create_fixtures( 
     | 
| 
      
 1089 
     | 
    
         
            +
                  create_fixtures("categories")
         
     | 
| 
      
 1090 
     | 
    
         
            +
                  create_fixtures("authors")
         
     | 
| 
       730 
1091 
     | 
    
         
             
                end
         
     | 
| 
       731 
1092 
     | 
    
         | 
| 
       732 
     | 
    
         
            -
                load_extra_fixture( 
     | 
| 
       733 
     | 
    
         
            -
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection,  
     | 
| 
      
 1093 
     | 
    
         
            +
                load_extra_fixture("posts")
         
     | 
| 
      
 1094 
     | 
    
         
            +
                assert ActiveRecord::FixtureSet.fixture_is_cached?(ActiveRecord::Base.connection, "posts")
         
     | 
| 
       734 
1095 
     | 
    
         
             
                self.class.setup_fixture_accessors :posts
         
     | 
| 
       735 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 1096 
     | 
    
         
            +
                assert_equal "Welcome to the weblog", posts(:welcome).title
         
     | 
| 
       736 
1097 
     | 
    
         
             
              end
         
     | 
| 
       737 
1098 
     | 
    
         
             
            end
         
     | 
| 
       738 
1099 
     | 
    
         | 
| 
       739 
1100 
     | 
    
         
             
            class FoxyFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1101 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 1102 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
       740 
1103 
     | 
    
         
             
              fixtures :parrots, :parrots_pirates, :pirates, :treasures, :mateys, :ships, :computers,
         
     | 
| 
       741 
1104 
     | 
    
         
             
                       :developers, :"admin/accounts", :"admin/users", :live_parrots, :dead_parrots, :books
         
     | 
| 
       742 
1105 
     | 
    
         | 
| 
       743 
     | 
    
         
            -
              if ActiveRecord::Base.connection.adapter_name ==  
     | 
| 
       744 
     | 
    
         
            -
                require  
     | 
| 
       745 
     | 
    
         
            -
                require  
     | 
| 
      
 1106 
     | 
    
         
            +
              if ActiveRecord::Base.connection.adapter_name == "PostgreSQL"
         
     | 
| 
      
 1107 
     | 
    
         
            +
                require "models/uuid_parent"
         
     | 
| 
      
 1108 
     | 
    
         
            +
                require "models/uuid_child"
         
     | 
| 
       746 
1109 
     | 
    
         
             
                fixtures :uuid_parents, :uuid_children
         
     | 
| 
       747 
1110 
     | 
    
         
             
              end
         
     | 
| 
       748 
1111 
     | 
    
         | 
| 
         @@ -759,21 +1122,21 @@ class FoxyFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       759 
1122 
     | 
    
         
             
                assert_equal 207281424, ActiveRecord::FixtureSet.identify(:ruby)
         
     | 
| 
       760 
1123 
     | 
    
         
             
                assert_equal 1066363776, ActiveRecord::FixtureSet.identify(:sapphire_2)
         
     | 
| 
       761 
1124 
     | 
    
         | 
| 
       762 
     | 
    
         
            -
                assert_equal  
     | 
| 
       763 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 1125 
     | 
    
         
            +
                assert_equal "f92b6bda-0d0d-5fe1-9124-502b18badded", ActiveRecord::FixtureSet.identify(:daddy, :uuid)
         
     | 
| 
      
 1126 
     | 
    
         
            +
                assert_equal "b4b10018-ad47-595d-b42f-d8bdaa6d01bf", ActiveRecord::FixtureSet.identify(:sonny, :uuid)
         
     | 
| 
       764 
1127 
     | 
    
         
             
              end
         
     | 
| 
       765 
1128 
     | 
    
         | 
| 
       766 
1129 
     | 
    
         
             
              TIMESTAMP_COLUMNS = %w(created_at created_on updated_at updated_on)
         
     | 
| 
       767 
1130 
     | 
    
         | 
| 
       768 
1131 
     | 
    
         
             
              def test_populates_timestamp_columns
         
     | 
| 
       769 
1132 
     | 
    
         
             
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
       770 
     | 
    
         
            -
                  assert_not_nil(parrots(:george). 
     | 
| 
      
 1133 
     | 
    
         
            +
                  assert_not_nil(parrots(:george).public_send(property), "should set #{property}")
         
     | 
| 
       771 
1134 
     | 
    
         
             
                end
         
     | 
| 
       772 
1135 
     | 
    
         
             
              end
         
     | 
| 
       773 
1136 
     | 
    
         | 
| 
       774 
1137 
     | 
    
         
             
              def test_does_not_populate_timestamp_columns_if_model_has_set_record_timestamps_to_false
         
     | 
| 
       775 
1138 
     | 
    
         
             
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
       776 
     | 
    
         
            -
                  assert_nil(ships(:black_pearl). 
     | 
| 
      
 1139 
     | 
    
         
            +
                  assert_nil(ships(:black_pearl).public_send(property), "should not set #{property}")
         
     | 
| 
       777 
1140 
     | 
    
         
             
                end
         
     | 
| 
       778 
1141 
     | 
    
         
             
              end
         
     | 
| 
       779 
1142 
     | 
    
         | 
| 
         @@ -781,7 +1144,7 @@ class FoxyFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       781 
1144 
     | 
    
         
             
                last = nil
         
     | 
| 
       782 
1145 
     | 
    
         | 
| 
       783 
1146 
     | 
    
         
             
                TIMESTAMP_COLUMNS.each do |property|
         
     | 
| 
       784 
     | 
    
         
            -
                  current = parrots(:george). 
     | 
| 
      
 1147 
     | 
    
         
            +
                  current = parrots(:george).public_send(property)
         
     | 
| 
       785 
1148 
     | 
    
         
             
                  last ||= current
         
     | 
| 
       786 
1149 
     | 
    
         | 
| 
       787 
1150 
     | 
    
         
             
                  assert_equal(last, current)
         
     | 
| 
         @@ -829,13 +1192,13 @@ class FoxyFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       829 
1192 
     | 
    
         
             
              def test_supports_inline_habtm
         
     | 
| 
       830 
1193 
     | 
    
         
             
                assert(parrots(:george).treasures.include?(treasures(:diamond)))
         
     | 
| 
       831 
1194 
     | 
    
         
             
                assert(parrots(:george).treasures.include?(treasures(:sapphire)))
         
     | 
| 
       832 
     | 
    
         
            -
                 
     | 
| 
      
 1195 
     | 
    
         
            +
                assert_not(parrots(:george).treasures.include?(treasures(:ruby)))
         
     | 
| 
       833 
1196 
     | 
    
         
             
              end
         
     | 
| 
       834 
1197 
     | 
    
         | 
| 
       835 
1198 
     | 
    
         
             
              def test_supports_inline_habtm_with_specified_id
         
     | 
| 
       836 
1199 
     | 
    
         
             
                assert(parrots(:polly).treasures.include?(treasures(:ruby)))
         
     | 
| 
       837 
1200 
     | 
    
         
             
                assert(parrots(:polly).treasures.include?(treasures(:sapphire)))
         
     | 
| 
       838 
     | 
    
         
            -
                 
     | 
| 
      
 1201 
     | 
    
         
            +
                assert_not(parrots(:polly).treasures.include?(treasures(:diamond)))
         
     | 
| 
       839 
1202 
     | 
    
         
             
              end
         
     | 
| 
       840 
1203 
     | 
    
         | 
| 
       841 
1204 
     | 
    
         
             
              def test_supports_yaml_arrays
         
     | 
| 
         @@ -885,20 +1248,20 @@ class FoxyFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       885 
1248 
     | 
    
         
             
              end
         
     | 
| 
       886 
1249 
     | 
    
         | 
| 
       887 
1250 
     | 
    
         
             
              def test_namespaced_models
         
     | 
| 
       888 
     | 
    
         
            -
                 
     | 
| 
      
 1251 
     | 
    
         
            +
                assert_includes admin_accounts(:signals37).users, admin_users(:david)
         
     | 
| 
       889 
1252 
     | 
    
         
             
                assert_equal 2, admin_accounts(:signals37).users.size
         
     | 
| 
       890 
1253 
     | 
    
         
             
              end
         
     | 
| 
       891 
1254 
     | 
    
         | 
| 
       892 
1255 
     | 
    
         
             
              def test_resolves_enums
         
     | 
| 
       893 
     | 
    
         
            -
                 
     | 
| 
       894 
     | 
    
         
            -
                 
     | 
| 
       895 
     | 
    
         
            -
                 
     | 
| 
       896 
     | 
    
         
            -
                 
     | 
| 
      
 1256 
     | 
    
         
            +
                assert_predicate books(:awdr), :published?
         
     | 
| 
      
 1257 
     | 
    
         
            +
                assert_predicate books(:awdr), :read?
         
     | 
| 
      
 1258 
     | 
    
         
            +
                assert_predicate books(:rfr), :proposed?
         
     | 
| 
      
 1259 
     | 
    
         
            +
                assert_predicate books(:ddd), :published?
         
     | 
| 
       897 
1260 
     | 
    
         
             
              end
         
     | 
| 
       898 
1261 
     | 
    
         
             
            end
         
     | 
| 
       899 
1262 
     | 
    
         | 
| 
       900 
1263 
     | 
    
         
             
            class ActiveSupportSubclassWithFixturesTest < ActiveRecord::TestCase
         
     | 
| 
       901 
     | 
    
         
            -
              fixtures :parrots
         
     | 
| 
      
 1264 
     | 
    
         
            +
              fixtures :parrots, :pirates, :parrots_pirates, :treasures
         
     | 
| 
       902 
1265 
     | 
    
         | 
| 
       903 
1266 
     | 
    
         
             
              # This seemingly useless assertion catches a bug that caused the fixtures
         
     | 
| 
       904 
1267 
     | 
    
         
             
              # setup code call nil[]
         
     | 
| 
         @@ -910,14 +1273,14 @@ end 
     | 
|
| 
       910 
1273 
     | 
    
         
             
            class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase
         
     | 
| 
       911 
1274 
     | 
    
         
             
              ActiveRecord::FixtureSet.reset_cache
         
     | 
| 
       912 
1275 
     | 
    
         | 
| 
       913 
     | 
    
         
            -
              set_fixture_class :randomly_named_a9 
     | 
| 
      
 1276 
     | 
    
         
            +
              set_fixture_class :randomly_named_a9 =>
         
     | 
| 
       914 
1277 
     | 
    
         
             
                                    ClassNameThatDoesNotFollowCONVENTIONS,
         
     | 
| 
       915 
1278 
     | 
    
         
             
                                :'admin/randomly_named_a9' =>
         
     | 
| 
       916 
1279 
     | 
    
         
             
                                    Admin::ClassNameThatDoesNotFollowCONVENTIONS1,
         
     | 
| 
       917 
     | 
    
         
            -
                                 
     | 
| 
      
 1280 
     | 
    
         
            +
                                "admin/randomly_named_b0"  =>
         
     | 
| 
       918 
1281 
     | 
    
         
             
                                    Admin::ClassNameThatDoesNotFollowCONVENTIONS2
         
     | 
| 
       919 
1282 
     | 
    
         | 
| 
       920 
     | 
    
         
            -
              fixtures :randomly_named_a9,  
     | 
| 
      
 1283 
     | 
    
         
            +
              fixtures :randomly_named_a9, "admin/randomly_named_a9",
         
     | 
| 
       921 
1284 
     | 
    
         
             
                       :'admin/randomly_named_b0'
         
     | 
| 
       922 
1285 
     | 
    
         | 
| 
       923 
1286 
     | 
    
         
             
              def test_named_accessor_for_randomly_named_fixture_and_class
         
     | 
| 
         @@ -933,8 +1296,39 @@ class CustomNameForFixtureOrModelTest < ActiveRecord::TestCase 
     | 
|
| 
       933 
1296 
     | 
    
         
             
              end
         
     | 
| 
       934 
1297 
     | 
    
         | 
| 
       935 
1298 
     | 
    
         
             
              def test_table_name_is_defined_in_the_model
         
     | 
| 
       936 
     | 
    
         
            -
                assert_equal  
     | 
| 
       937 
     | 
    
         
            -
                assert_equal  
     | 
| 
      
 1299 
     | 
    
         
            +
                assert_equal "randomly_named_table2", ActiveRecord::FixtureSet.all_loaded_fixtures["admin/randomly_named_a9"].table_name
         
     | 
| 
      
 1300 
     | 
    
         
            +
                assert_equal "randomly_named_table2", Admin::ClassNameThatDoesNotFollowCONVENTIONS1.table_name
         
     | 
| 
      
 1301 
     | 
    
         
            +
              end
         
     | 
| 
      
 1302 
     | 
    
         
            +
            end
         
     | 
| 
      
 1303 
     | 
    
         
            +
             
     | 
| 
      
 1304 
     | 
    
         
            +
            class IgnoreFixturesTest < ActiveRecord::TestCase
         
     | 
| 
      
 1305 
     | 
    
         
            +
              fixtures :other_books, :parrots
         
     | 
| 
      
 1306 
     | 
    
         
            +
             
     | 
| 
      
 1307 
     | 
    
         
            +
              # Set to false to blow away fixtures cache and ensure our fixtures are loaded
         
     | 
| 
      
 1308 
     | 
    
         
            +
              # without interfering with other tests that use the same `model_class`.
         
     | 
| 
      
 1309 
     | 
    
         
            +
              self.use_transactional_tests = false
         
     | 
| 
      
 1310 
     | 
    
         
            +
             
     | 
| 
      
 1311 
     | 
    
         
            +
              test "ignores books fixtures" do
         
     | 
| 
      
 1312 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published) }
         
     | 
| 
      
 1313 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published_paperback) }
         
     | 
| 
      
 1314 
     | 
    
         
            +
                assert_raise(StandardError) { other_books(:published_ebook) }
         
     | 
| 
      
 1315 
     | 
    
         
            +
             
     | 
| 
      
 1316 
     | 
    
         
            +
                assert_equal 2, Book.count
         
     | 
| 
      
 1317 
     | 
    
         
            +
                assert_equal "Agile Web Development with Rails", other_books(:awdr).name
         
     | 
| 
      
 1318 
     | 
    
         
            +
                assert_equal "published", other_books(:awdr).status
         
     | 
| 
      
 1319 
     | 
    
         
            +
                assert_equal "paperback", other_books(:awdr).format
         
     | 
| 
      
 1320 
     | 
    
         
            +
                assert_equal "english", other_books(:awdr).language
         
     | 
| 
      
 1321 
     | 
    
         
            +
             
     | 
| 
      
 1322 
     | 
    
         
            +
                assert_equal "Ruby for Rails", other_books(:rfr).name
         
     | 
| 
      
 1323 
     | 
    
         
            +
                assert_equal "ebook", other_books(:rfr).format
         
     | 
| 
      
 1324 
     | 
    
         
            +
                assert_equal "published", other_books(:rfr).status
         
     | 
| 
      
 1325 
     | 
    
         
            +
              end
         
     | 
| 
      
 1326 
     | 
    
         
            +
             
     | 
| 
      
 1327 
     | 
    
         
            +
              test "ignores parrots fixtures" do
         
     | 
| 
      
 1328 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEFAULT) }
         
     | 
| 
      
 1329 
     | 
    
         
            +
                assert_raise(StandardError) { parrots(:DEAD_PARROT) }
         
     | 
| 
      
 1330 
     | 
    
         
            +
             
     | 
| 
      
 1331 
     | 
    
         
            +
                assert_equal "DeadParrot", parrots(:polly).parrot_sti_class
         
     | 
| 
       938 
1332 
     | 
    
         
             
              end
         
     | 
| 
       939 
1333 
     | 
    
         
             
            end
         
     | 
| 
       940 
1334 
     | 
    
         | 
| 
         @@ -962,15 +1356,15 @@ end 
     | 
|
| 
       962 
1356 
     | 
    
         | 
| 
       963 
1357 
     | 
    
         
             
            class FixtureClassNamesTest < ActiveRecord::TestCase
         
     | 
| 
       964 
1358 
     | 
    
         
             
              def setup
         
     | 
| 
       965 
     | 
    
         
            -
                @saved_cache =  
     | 
| 
      
 1359 
     | 
    
         
            +
                @saved_cache = fixture_class_names.dup
         
     | 
| 
       966 
1360 
     | 
    
         
             
              end
         
     | 
| 
       967 
1361 
     | 
    
         | 
| 
       968 
1362 
     | 
    
         
             
              def teardown
         
     | 
| 
       969 
     | 
    
         
            -
                 
     | 
| 
      
 1363 
     | 
    
         
            +
                fixture_class_names.replace(@saved_cache)
         
     | 
| 
       970 
1364 
     | 
    
         
             
              end
         
     | 
| 
       971 
1365 
     | 
    
         | 
| 
       972 
1366 
     | 
    
         
             
              test "fixture_class_names returns nil for unregistered identifier" do
         
     | 
| 
       973 
     | 
    
         
            -
                assert_nil  
     | 
| 
      
 1367 
     | 
    
         
            +
                assert_nil fixture_class_names["unregistered_identifier"]
         
     | 
| 
       974 
1368 
     | 
    
         
             
              end
         
     | 
| 
       975 
1369 
     | 
    
         
             
            end
         
     | 
| 
       976 
1370 
     | 
    
         | 
| 
         @@ -986,3 +1380,266 @@ class SameNameDifferentDatabaseFixturesTest < ActiveRecord::TestCase 
     | 
|
| 
       986 
1380 
     | 
    
         
             
                assert_kind_of OtherDog, other_dogs(:lassie)
         
     | 
| 
       987 
1381 
     | 
    
         
             
              end
         
     | 
| 
       988 
1382 
     | 
    
         
             
            end
         
     | 
| 
      
 1383 
     | 
    
         
            +
             
     | 
| 
      
 1384 
     | 
    
         
            +
            class NilFixturePathTest < ActiveRecord::TestCase
         
     | 
| 
      
 1385 
     | 
    
         
            +
              test "raises an error when all fixtures loaded" do
         
     | 
| 
      
 1386 
     | 
    
         
            +
                error = assert_raises(StandardError) do
         
     | 
| 
      
 1387 
     | 
    
         
            +
                  TestCase = Class.new(ActiveRecord::TestCase)
         
     | 
| 
      
 1388 
     | 
    
         
            +
                  TestCase.class_eval do
         
     | 
| 
      
 1389 
     | 
    
         
            +
                    self.fixture_path = nil
         
     | 
| 
      
 1390 
     | 
    
         
            +
                    fixtures :all
         
     | 
| 
      
 1391 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1392 
     | 
    
         
            +
                end
         
     | 
| 
      
 1393 
     | 
    
         
            +
                assert_equal <<~MSG.squish, error.message
         
     | 
| 
      
 1394 
     | 
    
         
            +
                  No fixture path found.
         
     | 
| 
      
 1395 
     | 
    
         
            +
                  Please set `NilFixturePathTest::TestCase.fixture_path`.
         
     | 
| 
      
 1396 
     | 
    
         
            +
                MSG
         
     | 
| 
      
 1397 
     | 
    
         
            +
              end
         
     | 
| 
      
 1398 
     | 
    
         
            +
            end
         
     | 
| 
      
 1399 
     | 
    
         
            +
             
     | 
| 
      
 1400 
     | 
    
         
            +
            class FileFixtureConflictTest < ActiveRecord::TestCase
         
     | 
| 
      
 1401 
     | 
    
         
            +
              def self.file_fixture_path
         
     | 
| 
      
 1402 
     | 
    
         
            +
                FIXTURES_ROOT + "/all/admin"
         
     | 
| 
      
 1403 
     | 
    
         
            +
              end
         
     | 
| 
      
 1404 
     | 
    
         
            +
             
     | 
| 
      
 1405 
     | 
    
         
            +
              test "ignores file fixtures" do
         
     | 
| 
      
 1406 
     | 
    
         
            +
                self.class.fixture_path = FIXTURES_ROOT + "/all"
         
     | 
| 
      
 1407 
     | 
    
         
            +
                self.class.fixtures :all
         
     | 
| 
      
 1408 
     | 
    
         
            +
             
     | 
| 
      
 1409 
     | 
    
         
            +
                assert_equal %w(developers namespaced/accounts people tasks), fixture_table_names.sort
         
     | 
| 
      
 1410 
     | 
    
         
            +
              end
         
     | 
| 
      
 1411 
     | 
    
         
            +
            end
         
     | 
| 
      
 1412 
     | 
    
         
            +
             
     | 
| 
      
 1413 
     | 
    
         
            +
            if current_adapter?(:SQLite3Adapter) && !in_memory_db?
         
     | 
| 
      
 1414 
     | 
    
         
            +
              class MultipleFixtureConnectionsTest < ActiveRecord::TestCase
         
     | 
| 
      
 1415 
     | 
    
         
            +
                include ActiveRecord::TestFixtures
         
     | 
| 
      
 1416 
     | 
    
         
            +
             
     | 
| 
      
 1417 
     | 
    
         
            +
                fixtures :dogs
         
     | 
| 
      
 1418 
     | 
    
         
            +
             
     | 
| 
      
 1419 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 1420 
     | 
    
         
            +
                  @old_handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1421 
     | 
    
         
            +
                  @prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
         
     | 
| 
      
 1422 
     | 
    
         
            +
                  db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
         
     | 
| 
      
 1423 
     | 
    
         
            +
             
     | 
| 
      
 1424 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1425 
     | 
    
         
            +
             
     | 
| 
      
 1426 
     | 
    
         
            +
                  handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
      
 1427 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = handler
         
     | 
| 
      
 1428 
     | 
    
         
            +
                  handler.establish_connection(db_config)
         
     | 
| 
      
 1429 
     | 
    
         
            +
             
     | 
| 
      
 1430 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
         
     | 
| 
      
 1431 
     | 
    
         
            +
             
     | 
| 
      
 1432 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1433 
     | 
    
         
            +
                end
         
     | 
| 
      
 1434 
     | 
    
         
            +
             
     | 
| 
      
 1435 
     | 
    
         
            +
                def teardown
         
     | 
| 
      
 1436 
     | 
    
         
            +
                  ActiveRecord::Base.configurations = @prev_configs
         
     | 
| 
      
 1437 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = @old_handler
         
     | 
| 
      
 1438 
     | 
    
         
            +
                  clean_up_connection_handler
         
     | 
| 
      
 1439 
     | 
    
         
            +
                end
         
     | 
| 
      
 1440 
     | 
    
         
            +
             
     | 
| 
      
 1441 
     | 
    
         
            +
                def test_uses_writing_connection_for_fixtures
         
     | 
| 
      
 1442 
     | 
    
         
            +
                  ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1443 
     | 
    
         
            +
                    Dog.first
         
     | 
| 
      
 1444 
     | 
    
         
            +
             
     | 
| 
      
 1445 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 1446 
     | 
    
         
            +
                      ActiveRecord::Base.connected_to(role: :writing) { Dog.create! alias: "Doggo" }
         
     | 
| 
      
 1447 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1448 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1449 
     | 
    
         
            +
                end
         
     | 
| 
      
 1450 
     | 
    
         
            +
             
     | 
| 
      
 1451 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same
         
     | 
| 
      
 1452 
     | 
    
         
            +
                  handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1453 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing).connection
         
     | 
| 
      
 1454 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading).connection
         
     | 
| 
      
 1455 
     | 
    
         
            +
             
     | 
| 
      
 1456 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1457 
     | 
    
         
            +
             
     | 
| 
      
 1458 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1459 
     | 
    
         
            +
             
     | 
| 
      
 1460 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing).connection
         
     | 
| 
      
 1461 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading).connection
         
     | 
| 
      
 1462 
     | 
    
         
            +
             
     | 
| 
      
 1463 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1464 
     | 
    
         
            +
                end
         
     | 
| 
      
 1465 
     | 
    
         
            +
             
     | 
| 
      
 1466 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_for_non_default_shards
         
     | 
| 
      
 1467 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1468 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1469 
     | 
    
         
            +
                    two: { writing: :default, reading: :readonly }
         
     | 
| 
      
 1470 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1471 
     | 
    
         
            +
             
     | 
| 
      
 1472 
     | 
    
         
            +
                  handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1473 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing, shard: :two).connection
         
     | 
| 
      
 1474 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading, shard: :two).connection
         
     | 
| 
      
 1475 
     | 
    
         
            +
             
     | 
| 
      
 1476 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1477 
     | 
    
         
            +
             
     | 
| 
      
 1478 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1479 
     | 
    
         
            +
             
     | 
| 
      
 1480 
     | 
    
         
            +
                  rw_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :writing, shard: :two).connection
         
     | 
| 
      
 1481 
     | 
    
         
            +
                  ro_conn = handler.retrieve_connection_pool("ActiveRecord::Base", role: :reading, shard: :two).connection
         
     | 
| 
      
 1482 
     | 
    
         
            +
             
     | 
| 
      
 1483 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1484 
     | 
    
         
            +
                end
         
     | 
| 
      
 1485 
     | 
    
         
            +
             
     | 
| 
      
 1486 
     | 
    
         
            +
                def test_only_existing_connections_are_replaced
         
     | 
| 
      
 1487 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1488 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1489 
     | 
    
         
            +
                    two: { writing: :default }
         
     | 
| 
      
 1490 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1491 
     | 
    
         
            +
             
     | 
| 
      
 1492 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1493 
     | 
    
         
            +
             
     | 
| 
      
 1494 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1495 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading, shard: :two) do
         
     | 
| 
      
 1496 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1497 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1498 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1499 
     | 
    
         
            +
                end
         
     | 
| 
      
 1500 
     | 
    
         
            +
             
     | 
| 
      
 1501 
     | 
    
         
            +
                def test_only_existing_connections_are_restored
         
     | 
| 
      
 1502 
     | 
    
         
            +
                  clean_up_connection_handler
         
     | 
| 
      
 1503 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1504 
     | 
    
         
            +
             
     | 
| 
      
 1505 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1506 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1507 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1508 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1509 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1510 
     | 
    
         
            +
                end
         
     | 
| 
      
 1511 
     | 
    
         
            +
             
     | 
| 
      
 1512 
     | 
    
         
            +
                private
         
     | 
| 
      
 1513 
     | 
    
         
            +
                  def config
         
     | 
| 
      
 1514 
     | 
    
         
            +
                    { "default" => default_config, "readonly" => readonly_config }
         
     | 
| 
      
 1515 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1516 
     | 
    
         
            +
             
     | 
| 
      
 1517 
     | 
    
         
            +
                  def default_config
         
     | 
| 
      
 1518 
     | 
    
         
            +
                    { "adapter" => "sqlite3", "database" => "test/fixtures/fixture_database.sqlite3" }
         
     | 
| 
      
 1519 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1520 
     | 
    
         
            +
             
     | 
| 
      
 1521 
     | 
    
         
            +
                  def readonly_config
         
     | 
| 
      
 1522 
     | 
    
         
            +
                    default_config.merge("replica" => true)
         
     | 
| 
      
 1523 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1524 
     | 
    
         
            +
              end
         
     | 
| 
      
 1525 
     | 
    
         
            +
             
     | 
| 
      
 1526 
     | 
    
         
            +
              class MultipleFixtureLegacyConnectionsTest < ActiveRecord::TestCase
         
     | 
| 
      
 1527 
     | 
    
         
            +
                include ActiveRecord::TestFixtures
         
     | 
| 
      
 1528 
     | 
    
         
            +
             
     | 
| 
      
 1529 
     | 
    
         
            +
                fixtures :dogs
         
     | 
| 
      
 1530 
     | 
    
         
            +
             
     | 
| 
      
 1531 
     | 
    
         
            +
                def setup
         
     | 
| 
      
 1532 
     | 
    
         
            +
                  @old_value = ActiveRecord::Base.legacy_connection_handling
         
     | 
| 
      
 1533 
     | 
    
         
            +
                  ActiveRecord::Base.legacy_connection_handling = true
         
     | 
| 
      
 1534 
     | 
    
         
            +
             
     | 
| 
      
 1535 
     | 
    
         
            +
                  @old_handler = ActiveRecord::Base.connection_handler
         
     | 
| 
      
 1536 
     | 
    
         
            +
                  @prev_configs, ActiveRecord::Base.configurations = ActiveRecord::Base.configurations, config
         
     | 
| 
      
 1537 
     | 
    
         
            +
                  db_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(ENV["RAILS_ENV"], "readonly", readonly_config)
         
     | 
| 
      
 1538 
     | 
    
         
            +
             
     | 
| 
      
 1539 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1540 
     | 
    
         
            +
             
     | 
| 
      
 1541 
     | 
    
         
            +
                  handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
         
     | 
| 
      
 1542 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = handler
         
     | 
| 
      
 1543 
     | 
    
         
            +
                  handler.establish_connection(db_config)
         
     | 
| 
      
 1544 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handlers = {}
         
     | 
| 
      
 1545 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to(database: { writing: :default, reading: :readonly })
         
     | 
| 
      
 1546 
     | 
    
         
            +
             
     | 
| 
      
 1547 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1548 
     | 
    
         
            +
                end
         
     | 
| 
      
 1549 
     | 
    
         
            +
             
     | 
| 
      
 1550 
     | 
    
         
            +
                def teardown
         
     | 
| 
      
 1551 
     | 
    
         
            +
                  ActiveRecord::Base.configurations = @prev_configs
         
     | 
| 
      
 1552 
     | 
    
         
            +
                  ActiveRecord::Base.connection_handler = @old_handler
         
     | 
| 
      
 1553 
     | 
    
         
            +
                  clean_up_legacy_connection_handlers
         
     | 
| 
      
 1554 
     | 
    
         
            +
                  ActiveRecord::Base.legacy_connection_handling = false
         
     | 
| 
      
 1555 
     | 
    
         
            +
                end
         
     | 
| 
      
 1556 
     | 
    
         
            +
             
     | 
| 
      
 1557 
     | 
    
         
            +
                def test_uses_writing_connection_for_fixtures
         
     | 
| 
      
 1558 
     | 
    
         
            +
                  ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1559 
     | 
    
         
            +
                    Dog.first
         
     | 
| 
      
 1560 
     | 
    
         
            +
             
     | 
| 
      
 1561 
     | 
    
         
            +
                    assert_nothing_raised do
         
     | 
| 
      
 1562 
     | 
    
         
            +
                      ActiveRecord::Base.connected_to(role: :writing) { Dog.create! alias: "Doggo" }
         
     | 
| 
      
 1563 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1564 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1565 
     | 
    
         
            +
                end
         
     | 
| 
      
 1566 
     | 
    
         
            +
             
     | 
| 
      
 1567 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_with_legacy_handling
         
     | 
| 
      
 1568 
     | 
    
         
            +
                  writing = ActiveRecord::Base.connection_handlers[:writing]
         
     | 
| 
      
 1569 
     | 
    
         
            +
                  reading = ActiveRecord::Base.connection_handlers[:reading]
         
     | 
| 
      
 1570 
     | 
    
         
            +
             
     | 
| 
      
 1571 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1572 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1573 
     | 
    
         
            +
             
     | 
| 
      
 1574 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1575 
     | 
    
         
            +
             
     | 
| 
      
 1576 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1577 
     | 
    
         
            +
             
     | 
| 
      
 1578 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1579 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base").connection
         
     | 
| 
      
 1580 
     | 
    
         
            +
             
     | 
| 
      
 1581 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1582 
     | 
    
         
            +
                end
         
     | 
| 
      
 1583 
     | 
    
         
            +
             
     | 
| 
      
 1584 
     | 
    
         
            +
                def test_writing_and_reading_connections_are_the_same_for_non_default_shards_with_legacy_handling
         
     | 
| 
      
 1585 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1586 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1587 
     | 
    
         
            +
                    two: { writing: :default, reading: :readonly }
         
     | 
| 
      
 1588 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1589 
     | 
    
         
            +
             
     | 
| 
      
 1590 
     | 
    
         
            +
                  writing = ActiveRecord::Base.connection_handlers[:writing]
         
     | 
| 
      
 1591 
     | 
    
         
            +
                  reading = ActiveRecord::Base.connection_handlers[:reading]
         
     | 
| 
      
 1592 
     | 
    
         
            +
             
     | 
| 
      
 1593 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1594 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1595 
     | 
    
         
            +
             
     | 
| 
      
 1596 
     | 
    
         
            +
                  assert_equal rw_conn, ro_conn
         
     | 
| 
      
 1597 
     | 
    
         
            +
             
     | 
| 
      
 1598 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1599 
     | 
    
         
            +
             
     | 
| 
      
 1600 
     | 
    
         
            +
                  rw_conn = writing.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1601 
     | 
    
         
            +
                  ro_conn = reading.retrieve_connection_pool("ActiveRecord::Base", shard: :two).connection
         
     | 
| 
      
 1602 
     | 
    
         
            +
             
     | 
| 
      
 1603 
     | 
    
         
            +
                  assert_not_equal rw_conn, ro_conn
         
     | 
| 
      
 1604 
     | 
    
         
            +
                end
         
     | 
| 
      
 1605 
     | 
    
         
            +
             
     | 
| 
      
 1606 
     | 
    
         
            +
                def test_only_existing_connections_are_replaced
         
     | 
| 
      
 1607 
     | 
    
         
            +
                  ActiveRecord::Base.connects_to shards: {
         
     | 
| 
      
 1608 
     | 
    
         
            +
                    default: { writing: :default, reading: :readonly },
         
     | 
| 
      
 1609 
     | 
    
         
            +
                    two: { writing: :default }
         
     | 
| 
      
 1610 
     | 
    
         
            +
                  }
         
     | 
| 
      
 1611 
     | 
    
         
            +
             
     | 
| 
      
 1612 
     | 
    
         
            +
                  setup_shared_connection_pool
         
     | 
| 
      
 1613 
     | 
    
         
            +
             
     | 
| 
      
 1614 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1615 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading, shard: :two) do
         
     | 
| 
      
 1616 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1617 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1618 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1619 
     | 
    
         
            +
                end
         
     | 
| 
      
 1620 
     | 
    
         
            +
             
     | 
| 
      
 1621 
     | 
    
         
            +
                def test_only_existing_connections_are_restored
         
     | 
| 
      
 1622 
     | 
    
         
            +
                  clean_up_legacy_connection_handlers
         
     | 
| 
      
 1623 
     | 
    
         
            +
                  teardown_shared_connection_pool
         
     | 
| 
      
 1624 
     | 
    
         
            +
             
     | 
| 
      
 1625 
     | 
    
         
            +
                  assert_raises(ActiveRecord::ConnectionNotEstablished) do
         
     | 
| 
      
 1626 
     | 
    
         
            +
                    ActiveRecord::Base.connected_to(role: :reading) do
         
     | 
| 
      
 1627 
     | 
    
         
            +
                      ActiveRecord::Base.retrieve_connection
         
     | 
| 
      
 1628 
     | 
    
         
            +
                    end
         
     | 
| 
      
 1629 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1630 
     | 
    
         
            +
                end
         
     | 
| 
      
 1631 
     | 
    
         
            +
             
     | 
| 
      
 1632 
     | 
    
         
            +
                private
         
     | 
| 
      
 1633 
     | 
    
         
            +
                  def config
         
     | 
| 
      
 1634 
     | 
    
         
            +
                    { "default" => default_config, "readonly" => readonly_config }
         
     | 
| 
      
 1635 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1636 
     | 
    
         
            +
             
     | 
| 
      
 1637 
     | 
    
         
            +
                  def default_config
         
     | 
| 
      
 1638 
     | 
    
         
            +
                    { "adapter" => "sqlite3", "database" => "test/fixtures/fixture_database.sqlite3" }
         
     | 
| 
      
 1639 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1640 
     | 
    
         
            +
             
     | 
| 
      
 1641 
     | 
    
         
            +
                  def readonly_config
         
     | 
| 
      
 1642 
     | 
    
         
            +
                    default_config.merge("replica" => true)
         
     | 
| 
      
 1643 
     | 
    
         
            +
                  end
         
     | 
| 
      
 1644 
     | 
    
         
            +
              end
         
     | 
| 
      
 1645 
     | 
    
         
            +
            end
         
     |